I have problem with AppBarUtils, Eariler I have command in my appBar and when it run. However something broke. My Main.xaml
<phone:PhoneApplicationPage
x:Class="OsiÄ…gnijCelPhoneApp.Views.Main"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:appBarUtils="clr-namespace:AppBarUtils;assembly=AppBarUtils"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
DataContext="{Binding Source={StaticResource Locator}, Path=Main}"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="login"/>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
<!--<i:Interaction.Behaviors>
<appBarUtils:AppBarItemCommand Id="login" Command="{Binding LoginIn,Mode=TwoWay}"/>
</i:Interaction.Behaviors>-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button Margin="25,0,0,355" Content="Zaloguj" Command="{Binding LoginIn,Mode=TwoWay}" />
</Grid>
</Grid>
</phone:PhoneApplicationPage>
I use Telerik, MVVM light, and AppBarUtils. I preinstalled AppBarUtils.
When I deploy my on phone, that I got
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in System.Windows.ni.dll Additional information: Unknown parser error: Scanner 2148474880. [Line: 25 Position: 29]
I think that it is problem with System.Windows.Interactive, because if I comment it, rest run.I debug on arm.
You havent set the interaction triggers. See this example http://allenlooplee.wordpress.com/2011/08/26/how-to-do-command-binding-for-application-bar-with-appbarutils-in-xaml/
Related
I want to display the default message when list box is empty and for same I used following code but this code is not working :
<HubSection x:Name="PivotFromAccount" Style="{StaticResource HubSectionStyle2}" >
<DataTemplate>
<Border Style="{StaticResource brdhubsectionstyle}">
<Grid Grid.Row="1" Style="{StaticResource GridMainStyleHubSession}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border Style="{StaticResource brdheaderstyle}">
<TextBlock Text="From Account" Style="{StaticResource lblheaderstyle}" />
</Border>
<ListBox x:Name="lstAccountDetailsfrom" Grid.Row="1" ItemsSource="{Binding }"
Style="{StaticResource LstBoxStyleBranches}"
Tapped="lstAccountDetailsfrom_Tapped"
ItemContainerStyle="{StaticResource lstAccountliststyle}"
ItemTemplate="{StaticResource lstAccountlistDataTemplate}" >
</ListBox>
<TextBlock Margin="4" FontStyle="Italic" FontSize="12" Text="List is empty" x:Name="txtmessage" Grid.Row="1" Foreground="Black" />
<i:Interaction.Behaviors>
<ic:DataTriggerBehavior Binding="{Binding ElementName=lstAccountDetailsfrom, Path=Items.Count,Converter={StaticResource DataTriggerBehavior},Mode=TwoWay}" Value="0" ComparisonCondition="GreaterThan">
<ic:ChangePropertyAction TargetObject="{Binding ElementName=txtmessage}" PropertyName="Visibility" Value="Collapsed"/>
</ic:DataTriggerBehavior>
</i:Interaction.Behaviors>
</Grid>
</Border>
</DataTemplate>
</HubSection>
I tried with the Ivalue converter also like below but it is also not much more helpful. It is always sending 0 count to ValueConverter
<TextBlock Margin="4" FontStyle="Italic" FontSize="12" Text="List is empty" x:Name="txtmessage" Grid.Row="1" Foreground="Black" Visibility="{Binding ElementName=lstAccountDetailsfrom,Converter={StaticResource DataTriggerBehavior},Mode=TwoWay}" />
If your data source is an ObservableCollection you can bind to its Count property with a custom IValueConverter than converts 0 to Visible and 1 to Collapsed and use it on the TextBlock. No behavior needed.
I am developing an application and trying to achieve a sort of flip effect(like flipboard)
this is my xaml.
<Page.Resources>
<Storyboard x:Name="FlipBottomStoryboard">
<DoubleAnimation Duration="0:0:1.1" To="-80.9" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)" Storyboard.TargetName="grid" d:IsOptimized="True"/>
</Storyboard>
</Page.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<Grid Grid.RowSpan="2">
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Rectangle Stroke="Black" Fill="#FF4E608F"/>
</Grid>
<Grid x:Name="grid" Grid.Row="2" Grid.RowSpan="2" Canvas.ZIndex="1">
<Grid.Projection>
<PlaneProjection CenterOfRotationX="0" CenterOfRotationY="0"/>
</Grid.Projection>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="Tapped">
<Media:ControlStoryboardAction Storyboard="{StaticResource FlipBottomStoryboard}"/>
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
<Rectangle Fill="#FF3DDA24" Stroke="Black" Grid.Row="1"/>
</Grid>
<Rectangle Stroke="Black" Grid.Row="1" Grid.RowSpan="2">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="#FFA65757"/>
<GradientStop Color="#FF0A2E26" Offset="0.966"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
In short the grid on the lower half animates its RotationX when it is tapped.
The problem is that on the emulator(WVGA 4 inch 512mb) this works well but on the device (lumia 630 512mb) the animation jumps from the initial position to the end. Also the framerate drops to 30.
Any help is welcome on the matter
I have a UserControl:
<UserControl x:Class="WP8.Progress"
..................................
d:DesignHeight="800" d:DesignWidth="480">
<Grid x:Name="LayoutRoot" Background="Transparent">
<Rectangle Stretch="Fill" Opacity="0.75" Fill="DarkGray"/>
<StackPanel x:Name="stackPanel" Orientation="Vertical" VerticalAlignment="Center">
<ProgressBar Foreground="Blue" IsIndeterminate="True"/>
</StackPanel>
</Grid>
</UserControl>
I call UserControl in MainPage:
<phone:PhoneApplicationPage
x:Class="WP8.MainPage"
..................................
mc:Ignorable="d"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<Grid x:Name="LayoutRoot" Background="Black">
<Grid>
<Button Name="btnButton" Content="OK" Click="btnButton_Click"/>
</Grid>
<Grid>
<uc:Progress />
</Grid>
</Grid>
</phone:PhoneApplicationPage>
When i run app, i see UserControl upper MainPage but i still pressed button at MainPage.
How do i only action at UserControl?
I got your question i have done the same thing in my App when you are opening the UserControl set your LayoutRoot.IsHitTestVisible="False" and after then the user has done on the usercontrol or usercontrol is closed then set it as true. And you can also do some opacity or visibility changes if you want with the grid.
I am not able to display HTML content in Browser Field. My HTML:
namespace webviewTest
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
private const string htmlFragment =
"<html><body><h2>This is an HTML fragment</h2></body></html>";
WebView.NavigateToString(htmlFragment);
}
}
Xaml code:
<phone:PhoneApplicationPage
x:Class="webviewTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<phone:WebBrowser x:Name="WebView"></phone:WebBrowser>
</Grid>
</Grid>
I know I am doing some nonsense here. Please tell me how I can achieve this.
It works for me, could it be the way you've structured your code?
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
private const string htmlFragment =
"<html><body><h2>This is an HTML fragment</h2></body></html>";
protected override void OnNavigatedTo(NavigationEventArgs e)
{
WebView.NavigateToString(htmlFragment);
}
}
Xaml
<phone:PhoneApplicationPage
x:Class="webviewTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<Grid x:Name="ContentPanel" Margin="12,0,12,0">
<phone:WebBrowser x:Name="WebView" />
</Grid>
</phone:PhoneApplicationPage>
<StackPanel x:Name="LayoutRoot" Background="Transparent" >
<TextBlock Margin="20,20,0,0" Text="Type Text Here" HorizontalAlignment="Left"/>
<TextBox x:Name="SearchTextBox" IsReadOnly="False" HorizontalAlignment="Left" Margin="20,5,0,0" Height="70" Width="400" dp:TextBoxOnTextChangedDependency.UpdateSourceOnChange="True" Text="{Binding SearchBoxText, Mode=TwoWay}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="TextChanged">
<cmd:EventToCommand PassEventArgsToCommand="True"
Command="{Binding ElementName=SearchTextBox, Path=DataContext.SearchTextBox_TextChangedCommand}"
/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
<Grid x:Name="LayoutList" Background="{StaticResource PhoneChromeBrush}">
<toolkit:LongListMultiSelector x:Name="treksLocationItems" Background="Transparent"
ItemsSource="{Binding Path=TreksLocationItems}">
<toolkit:LongListMultiSelector.ItemTemplate>
<DataTemplate>
<Grid Margin="0,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Width="110" Height="150" Source="{Binding PictureFilename}" VerticalAlignment="Top"/>
<StackPanel Grid.Column="1" VerticalAlignment="Top">
<TextBlock Text="{Binding Name}" Style="{StaticResource PhoneTextLargeStyle}" FontFamily="{StaticResource PhoneFontFamilySemiBold}" Margin="12,-12,12,6"/>
<TextBlock Text="{Binding ShortDescription}" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap" FontFamily="{StaticResource PhoneFontFamilySemiBold}"/>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Address:" Style="{StaticResource PhoneTextSmallStyle}"/>
<TextBlock Text="{Binding Path=StreetName}" Style="{StaticResource PhoneTextSmallStyle}" FontFamily="{StaticResource PhoneFontFamilySemiBold}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Site:" Style="{StaticResource PhoneTextSmallStyle}"/>
<TextBlock Text="{Binding Path=Website}" Style="{StaticResource PhoneTextSmallStyle}" FontFamily="{StaticResource PhoneFontFamilySemiBold}"/>
</StackPanel>
</StackPanel>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Tap">
<cmd:EventToCommand Command="{Binding Path=DataContext.TapCommand, ElementName=searchItems}" CommandParameter="{Binding Path=Id}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Grid>
</DataTemplate>
</toolkit:LongListMultiSelector.ItemTemplate>
</toolkit:LongListMultiSelector>
</Grid>
</StackPanel>
I have this code in XAML, a textbox for search and a multi line select list. The problem is that the multiLineList is not scrollable even if there are many items. If I remove the stackpanel and the textblock and textbox, the list works ok with scroll enabled. Any suggestion?
Try adding a ScrollViewer above your grid.
<ScrollViewer>
<Grid x:Name="LayoutList" ....>
...
</Grid>
</ScrollViewer>
Or you could probably replace your Grid with a ScrollViewer if you're not using it to position your elements.
Wraping LLMS in a ScrollViewer will destroy the item virtualization and throw an OutOfMemoryException if the collection is too long.
Expose the LLMS' inner LongListSelector, then use the ScrollTo() method to scroll to the item u want.
LongListMultiSelector llms = LongListMultiSelector as LongListMultiSelector;
if (llms != null && llms.ItemsSource.Count > 0)
{
llms.InnerLongListSelector.ScrollTo(llms.ItemsSource[llms.ItemsSource.Count - 1]);
}
I've encountered this weird issue and found an easy solution.
It happens for both Longlistselector and LonglistMultiselector.
When you have several controls in one page, you need to set the height of selector's row to "*" instead of "Auto" in order to make the scrolling function to work correctly.
For example :
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/> //Row def for another row
<RowDefinition Height="*"/> //Row def for your selector
</Grid.RowDefinitions>
If the RowDefinition Height not set to "*" but "Auto", scrolling for Longlistselector will not response to user's action.