2 different stackpanels in a BottomAppBar Universal App - xaml

I am trying to put the elements in my BottomAppBar like that:
with this code I get the two stackpanels in the left,can you correct please my code:
<Page.BottomAppBar>
<CommandBar Background="#eff0f2">
<CommandBar.Content>
<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Left" Grid.Row="0" Grid.Column="0" VerticalAlignment="Stretch">
<Image Source="images/1.png" Height="35" Width="35" />
<ComboBox Margin="2" BorderThickness="0" SelectedItem="Français">
<ComboBoxItem Content="Français" />
<ComboBoxItem Content="Anglais" />
</ComboBox>
<Button VerticalAlignment="Stretch" Background="#eff0f2" >
<Button.Content>
<TextBlock Text="Conditions des données" Foreground="#336699"></TextBlock>
</Button.Content>
</Button>
<Button VerticalAlignment="Stretch" Background="#eff0f2" Margin="0">
<TextBlock Text="-Mentions légales" Foreground="#336699"></TextBlock>
</Button>
<Button VerticalAlignment="Stretch" Background="#eff0f2" Margin="0">
<TextBlock Text="-Impressum" Foreground="#336699"></TextBlock>
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="0" Grid.Column="1" >
<Image Source="images/marque.png" Height="35" Width="35" />
<TextBlock Text="2015 OAASE Corporation|All Right Reserved." Foreground="#666666" Margin="10" />
</StackPanel>
</Grid>
</CommandBar.Content>
</CommandBar>
</Page.BottomAppBar>
thanks for help :)

You just have to add Stretch HorizontalContentAlignment to CommandBar :
<CommandBar HorizontalContentAlignment="Stretch">
EDIT:
#user3821206, a quick fix for your problem of responsiveness is to set a minimum width to the first column, and set the width of the second column to Auto. When the screen is too small, the right part is cropped :
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="550" Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
A better and complementary fix is to use VisualStateManager and AdaptiveTrigger. For example, you can hide the right panel if the screen size is less than 720. To do that, give a name to your right Stackpanel :
<StackPanel x:Name="RightPanel"
And add the following snippet in the first container of your page (for me, it's a Grid) :
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<!-- Start of snippet -->
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
<!-- Edit style for small screen -->
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="RightPanel.Visibility"
Value="Collapsed" />
</VisualState.Setters>
</VisualState>
<VisualState>
<!-- Disable previous changes for large screen -->
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="720" />
</VisualState.StateTriggers>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<!-- End of snippet -->
</Grid>

Related

VisualStateManager doesn't update Grid properties when using nested Grid controls

Context: I want to use VisualStateManager to move a StackPanel to a different Grid column under certain conditions.
Problem: It seems that having nested Grid controls prevents my VisualState setter from being applied. In the example below (which has been simplified from the original code), the VisualState setter triggers if the OuterGrid is commented out, but won't fire when the OuterGrid is present.
Question: How can I trigger the VisualState setter when using nested grids?
Example:
<Grid x:Name="OuterGrid">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="12"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel
Grid.Column="0"
>
<Button
x:Name="Button1"
HorizontalAlignment="Stretch"
Content="Button1"
/>
</StackPanel>
<StackPanel
x:Name="Button2"
Grid.Column="2"
>
<HyperlinkButton
Height="36"
HorizontalAlignment="Stretch"
>
<TextBlock
Text="Button2"
/>
</HyperlinkButton>
</StackPanel>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ButtonAlignments">
<VisualState>
<!-- Move Button2 to the left column -->
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="600" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="Button2.(Grid.Column)" Value="0" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</Grid>
You need to define your Visual States at the root level of your XAML tree, as per docs.
Just move the your <VisualStateManager.VisualStateGroups> into the OuterGrid. I changed your sample a bit - it's working with Visibility instead of the Grid.Column:
<Grid x:Name="OuterGrid">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ButtonAlignments">
<VisualState>
<!-- Move Button2 to the left column -->
<VisualState.Setters>
<!--<Setter Target="Button2.(Grid.Column)"
Value="0" />-->
<Setter Target="Button2.(UIElement.Visibility)"
Value="Visible" />
</VisualState.Setters>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="600" />
</VisualState.StateTriggers>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="12" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<Button x:Name="Button1"
HorizontalAlignment="Stretch"
Content="Button1" />
</StackPanel>
<StackPanel x:Name="Button2"
Grid.Column="2"
Visibility="Collapsed">
<HyperlinkButton Height="36"
HorizontalAlignment="Stretch">
<TextBlock Text="Button2" />
</HyperlinkButton>
</StackPanel>
</Grid>
</Grid>

UWP Visual State Manager doesn't see content of DataTemplate

My page structure is shown below.
<ScrollViewer VerticalScrollBarVisibility="Auto">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="VisualStateGroup">
<VisualState x:Name="VisualStateNarrow">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="1"/>
</VisualState.StateTriggers>
<VisualState.Setters>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="VisualStateWide">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="800"/>
</VisualState.StateTriggers>
<VisualState.Setters>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Pivot x:Name="PivotPlatform" Margin="0" ItemsSource="{Binding PivotItems}" Grid.Row="2">
<Pivot.HeaderTemplate>
<DataTemplate>
<StackPanel Height="0" Width="0">
<TextBlock Text="{Binding}" />
</StackPanel>
</DataTemplate>
</Pivot.HeaderTemplate>
<Pivot.ItemTemplate>
<DataTemplate>
<Grid xmlns:uwp="using:AmazingPullToRefresh.Controls">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<uwp:PullToRefreshAdorner.Extender>
<uwp:PullToRefreshExtender RefreshRequested="PullToRefreshExtender_RefreshRequested" />
</uwp:PullToRefreshAdorner.Extender>
<RelativePanel x:Name="contentPanel" Grid.Row="0" Margin="10 -30 10 10">
<TextBlock Name="titleTB" Text="{Binding Title}" FontSize="12"
RelativePanel.AlignLeftWithPanel="True"
RelativePanel.AlignTopWithPanel="True"/>
<TextBlock Name="totalTB" Text="{Binding Total}" FontSize="18"
RelativePanel.AlignLeftWithPanel="True"
RelativePanel.Below="titleTB" />
<ProgressBar Name="progressBar" Value="{Binding ProgressValue}" Width="100" Foreground="{StaticResource currentThemeColor}"
RelativePanel.AlignLeftWithPanel="True" RelativePanel.Below="totalTB"
Margin="0 5 0 0"/>
<TextBlock Name="dateTB" Text="{Binding Date}" FontSize="16"
RelativePanel.AlignRightWithPanel="True"
RelativePanel.AlignTopWithPanel="True" />
</RelativePanel>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<Charting:Chart Grid.Row="1" x:Name="LineChart"
Margin="10" >
<Charting:LineSeries Title="" IndependentValuePath="Name" DependentValuePath="Amount"
IsSelectionEnabled="False" ItemsSource="{Binding Result}" />
</Charting:Chart>
</ScrollViewer>
</Grid>
</DataTemplate>
</Pivot.ItemTemplate>
</Pivot>
When I add setter for dateTB textblock into VisualState.Setters to move it to left side of Relative Panel, I get an error saying:
An animation is trying to modify an object named 'dateTB', but no such object can be found in the Page.
Code for adding the setter is:
<Setter Target="dateTB.(RelativePanel.AlignLeftWithPanel)" Value="True"/>
Is there a way to control this textblock through Visual State Manager with this page structure?
It's a problem of name scopes, common to all XAML UI frameworks. Your VSM is in the name scope of your UserControl or Page and the TextBlock is in a DataTemplate.
Romasz's solution to your problem to put the VSM inside of the DataTemplate puts everything you need in a single name scope and is the best solution to this problem.

How to dynamic change ItemTemplate width and height in ListView UWP?

I have a ListView like this
<ListView Name="lvTrailers"
Grid.Row="3"
SelectionChanged="lvTrailers_SelectionChanged"
SizeChanged="lvTrailers_SizeChanged">
<ListView.ItemTemplate>
<DataTemplate>
<Grid Height="65" Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="2.5*" />
</Grid.ColumnDefinitions>
<Image HorizontalAlignment="Center"
VerticalAlignment="Center"
Source="{Binding Thumbnail}"
Stretch="UniformToFill" />
<TextBlock Grid.Column="1"
Margin="10,5"
Text="{Binding Title}"
TextWrapping="Wrap" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
private void lvTrailers_SizeChanged(object sender, SizeChangedEventArgs e)
{
// add some userful code
// not working
lvTrailers.ItemTemplate.SetValue(HeightProperty, e.NewSize.Height / 6);
}
In UWP apps users can resize window height and width so when it happen, I want to dynamic resize ListView ItemTemplate too. Any one could tell me how to do that?
You need to use AdaptiveTrigger. Here is an example to achieve that :
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.Resources>
<DataTemplate x:Key="MyCustomItemDataTemplate">
<UserControl>
<Grid x:Name="content"
Margin="8"
Background="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="2.5*" />
</Grid.ColumnDefinitions>
<Image HorizontalAlignment="Center"
VerticalAlignment="Center"
Source="ms-appx:///Assets/StoreLogo.png"
Stretch="Uniform" />
<TextBlock Grid.Column="1"
Margin="10,5"
Text="blabla"
VerticalAlignment="Center"
TextWrapping="Wrap" />
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="Small">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="content.Height"
Value="30" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Wide">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="720" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="content.Height"
Value="Auto" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</UserControl>
</DataTemplate>
</Grid.Resources>
<ListView Name="items"
ItemTemplate="{StaticResource MyCustomItemDataTemplate}" />
</Grid>

Login-popup not working when rotating

I have a code that looks like this
<Popup IsOpen="True" Margin="200" Height="260" Width="900">
<Grid Height="250">
<TextBlock Style="{StaticResource HeaderTextStyle}" Text="Login" Margin="0" HorizontalAlignment="Center" VerticalAlignment="Top" Height="50" />
<TextBlock Style="{StaticResource ResourceKey=SubheaderTextStyle}" Text="" Margin="0,63,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" />
<TextBox Name="InputUsername" Margin="0,63,0,0" HorizontalAlignment="Right" Height="40" Width="650"/>
<TextBlock Style="{StaticResource ResourceKey=SubheaderTextStyle}" Text="" Margin="0,138,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<PasswordBox Name="InputPassword" Margin="0,0,138,0" HorizontalAlignment="Right" VerticalAlignment="Top" Height="40" Width="650" />
<Button Name="Login" Content="" Margin="200,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Bottom" />
<Button Name="Cancel" x:Uid="LoginPopupCancel" Content="" Margin="300,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Bottom" />
</Grid>
</Popup>
But it does not work, when I rotate the screen, what could be wrong?
UPDATE
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource ResourceKey=SubheaderTextStyle}" Text="Brugernavn" />
<TextBox Name="InputUsername" />
<TextBlock Style="{StaticResource ResourceKey=SubheaderTextStyle}" Text="Adgangskode" />
<PasswordBox Name="InputPassword" />
</Grid>
I am trying to find a fix, but this sets all the boxes and blocks below each other, how can I fix this?
D'oh I forgot to set Grid.Column and Grid.Row
You need to add a Visual State for the Portrait view and, inside of it, handle the position of the Popup Element.
<VisualState x:Name="FullScreenPortrait">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Margin"> <!--Example-->
<DiscreteObjectKeyFrame KeyTime="0" Value="0,0,0,0"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
You need to target every component adjust the Margin so they fit and look good. Otherwise, you can just support the landscape view and your problem is over.

Snap view not functioning properly?

I coded an app in windows 8 consumer preview and i was not aware of view box, so the app doesn't fit for particular resolutions then i used view box to make the app fit for all the available resolutions, after i ported the app to windows 8 release preview. After i used view box, snap view is not functioning properly. But i'm sure that snap was working fine before i used viewbox. i am unable to find the bug.
xaml of the page:
`
<Viewbox HorizontalAlignment="Left" VerticalAlignment="Top" >
<Grid x:Name="RootGrid" Background="#FF14B01B" Height="768" Width="1366">
<!-- Snap view title grid. -->
<Grid x:Name="SnapViewTitleGrid" Visibility="Collapsed" Height="140" VerticalAlignment="Top" MinHeight="140">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button x:Name="backButton3" Click="GoBack"
IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}"
Style="{StaticResource SnappedBackButtonStyle}"
Grid.Row="0"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Margin="10,0,0,0"
Grid.ColumnSpan="2"/>
<TextBlock x:Name="snappageTitle"
Text="{StaticResource AppName}"
FontSize="26.667"
FontWeight="Bold"
HorizontalAlignment="Left"
Margin="10,0,0,0"
Grid.Row="1"
Grid.Column="0" />
<Image x:Name="snapmyLogo"
Source="images/Logo.png"
Stretch="Fill"
Grid.Row="1"
Grid.Column="1"
Width="37"
Height="38"
Margin="0,0,10,0"
HorizontalAlignment="Right"
VerticalAlignment="Top"/>
<TextBlock x:Name="snapsubtitle"
HorizontalAlignment="Left"
Grid.Row="2"
Grid.ColumnSpan="2"
TextWrapping="Wrap"
Text="Learn your alphabets"
VerticalAlignment="Top"
Margin="10,0,0,0"
Width="275"
FontSize="20.667" />
</Grid>
<!-- Snap view content grid. -->
<Grid x:Name="SnapViewContentGrid" Grid.Row="1" Margin="0,0,0,-24" Height="760" Visibility="Collapsed" VerticalAlignment="Bottom">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Image box. -->
<Grid x:Name="ImageGrid2"
Grid.Row="0"
Background="#FF08635E">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image x:Name="imgAlpha2"
Source="images/A.png"
Margin="5,0,5,0"
Grid.Row="0" Height="513" />
<TextBlock x:Name="txtFor2"
Grid.Row="1"
Margin="5,0,5,10"
TextWrapping="Wrap"
Text="for APPLE"
FontSize="40"
FontFamily="Segoe UI" />
</Grid>
<!-- Play button -->
<Image Grid.Row="1"
Source="images/Play-01.png"
Width="42" Height="41"
Margin="0,0,5,10"
HorizontalAlignment="Right"
VerticalAlignment="Top"
/>
</Grid>
<!-- Back button and page title -->
<Grid x:Name="TitleGrid" Margin="1,4,-1,624" Grid.RowSpan="2" Visibility="Visible">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button x:Name="backButton" Style="{StaticResource BackButtonStyle}" Click="backButton_Click"/>
<TextBlock x:Name="pageTitle"
Grid.Column="1"
Text="{StaticResource AppName}"
Style="{StaticResource PageHeaderTextStyle}"
Margin="0,0,40,50"
Foreground="White" />
<TextBlock x:Name="subtitle"
Grid.Column="1"
HorizontalAlignment="Left"
Height="50"
Margin="0,105,0,-15"
TextWrapping="Wrap"
Text="Learn to write the alphabet"
VerticalAlignment="Top"
Width="333"
FontSize="26.667" />
<Image x:Name="myLogo"
Grid.Column="1"
Margin="0,60,60,0"
Source="images/Logo.png"
Stretch="Fill"
Width="74"
Height="76"
HorizontalAlignment="Right"
VerticalAlignment="Top"/>
</Grid>
<ScrollViewer x:Name="myScroll"
HorizontalAlignment="Left"
VerticalAlignment="Top"
VerticalScrollBarVisibility="Hidden"
HorizontalScrollBarVisibility="Auto" Margin="-7.257,135.551,0,-2.552" Grid.RowSpan="2" Visibility="Visible" >
<Grid x:Name="Allcontent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="120,20,35,35">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<!-- Image box on the left. -->
<Grid x:Name="ImageGrid"
Grid.Column="0"
Background="#FF08635E" Margin="3.056,0,6.944,10">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image x:Name="imgAlpha"
Source="images/A.png"
Grid.Row="0" Margin="0"/>
<TextBlock x:Name="txtFor"
Grid.Row="1"
TextWrapping="Wrap"
Text="for APPLE"
FontSize="80"
Margin="0"
FontFamily="Segoe UI"/>
</Grid>
<Grid x:Name="TraceGrid"
Grid.Column="1" Margin="46.662,0,-46.662,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="10*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- Play button -->
<Image x:Name="playB" Grid.Row="0" Grid.Column="0"
Source="images/play.png"
Width="42" Height="41"
HorizontalAlignment="Center"
VerticalAlignment="Top"
ToolTipService.ToolTip="Play it!" PointerPressed="playB_PointerPressed" />
<!-- Help text -->
<TextBlock Text="Practice tracing the letter here"
Grid.Row="0" Grid.Column="1"
FontSize="24" Margin="134.5,8" d:LayoutOverrides="Width, Height"/>
<!-- Color palette -->
<Grid x:Name="colorsPanel"
Grid.Row="0" Grid.Column="1"
ToolTipService.ToolTip="Choose a Color" Margin="566,0,43,0" RenderTransformOrigin="0.5,0.5" Grid.ColumnSpan="2">
<Grid.RenderTransform>
<CompositeTransform ScaleX="-1"/>
</Grid.RenderTransform>
<Grid x:Name="orangeGrid" Height="35" Width="39" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="86,-1.5,-86,11.5" PointerPressed="orangeGrid_PointerPressed" Background="#FFF1BC2D" />
<Grid x:Name="redGrid" Height="35" Width="39" HorizontalAlignment="Center" VerticalAlignment="Center" Background="#FFF51111" Margin="101.5,-1.5,18.5,11.5" PointerPressed="redGrid_PointerPressed"/>
<Grid x:Name="blueGrid" Height="35" Width="39" HorizontalAlignment="Center" VerticalAlignment="Center" Background="#FF1E27DE" Margin="-1,-1.5,1,11.5" PointerPressed="blueGrid_PointerPressed"/>
<Grid x:Name="greenGrid" Height="35" Width="39" HorizontalAlignment="Center" VerticalAlignment="Center" Background="#FF158B2B" Margin="-44.5,-1.5,44.5,11.5" PointerPressed="greenGrid_PointerPressed"/>
</Grid>
<!-- Grid with big background text and validate/clear buttons -->
<Grid Grid.Row="1" Grid.ColumnSpan="3" Margin="0,10,10,10" HorizontalAlignment="Center" VerticalAlignment="Center" >
<!-- Big background text + Ink Grid -->
<TextBlock x:Name="bgmtxt"
Text="A"
Grid.Column="0"
FontSize="400"
FontFamily="Segoe UI"
FontStretch="Undefined"
FontWeight="ExtraBold"
HorizontalAlignment="Center"
VerticalAlignment="Center"
TextWrapping="Wrap" Height="523" Margin="267,10,96.111,0" Width="436.889" />
<Grid x:Name="InkGrid"
Grid.Column="0"
HorizontalAlignment="Stretch"
Background="#FFE6E6E6"
Opacity="0.5"
Canvas.ZIndex="49"
Margin="0,0,10,10" Height="523" Width="787" PointerPressed="InkGrid_PointerPressed" PointerMoved="InkGrid_PointerMoved" PointerReleased="InkGrid_PointerReleased" PointerExited="InkGrid_PointerExited" />
</Grid>
</Grid>
</Grid>
</ScrollViewer>
<MediaElement x:Name="myMedia" HorizontalAlignment="Left" Height="0" Margin="600,53,0,0" Grid.Row="1" VerticalAlignment="Top" Width="0" RenderTransformOrigin="0.5,0.5" IsTapEnabled="False" IsRightTapEnabled="False" IsHoldingEnabled="False" AutoPlay="True">
<MediaElement.RenderTransform>
<CompositeTransform ScaleX="-1"/>
</MediaElement.RenderTransform>
</MediaElement>
</Grid>
<VisualStateManager.VisualStateGroups>
<!-- Visual states reflect the application's view state -->
<VisualStateGroup>
<VisualState x:Name="FullScreenLandscape"/>
<VisualState x:Name="Filled"/>
<!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
<VisualState x:Name="FullScreenPortrait" />
<!-- The back button and title have different styles when snapped -->
<VisualState x:Name="Snapped">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="myScroll" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="TitleGrid" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
</ObjectAnimationUsingKeyFrames>
<!--<ObjectAnimationUsingKeyFrames Storyboard.TargetName="AppBar" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
</ObjectAnimationUsingKeyFrames>-->
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="SnapViewTitleGrid" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="SnapViewContentGrid" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Viewbox>
<Page.BottomAppBar>
<AppBar x:Name="AppBar" >
<Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Width="221.556" Margin="0,0,4.417,0" >
<Button x:Name="ValidateB"
VerticalAlignment="Stretch" Click="ValidateB_Click" Width="92" BorderThickness="0" Style="{StaticResource AppBarButtonStyle}" >
<Button.Content>
<Image Source="images/validate.png" ></Image>
</Button.Content>
</Button>
<Button x:Name="ClearB"
VerticalAlignment="Stretch" Click="ClearB_Click" HorizontalAlignment="Right" Width="103" Margin="34,0,0,0" BorderThickness="0" Style="{StaticResource AppBarButtonStyle}" >
<Button.Content>
<Image Source="images/clear.png" ></Image>
</Button.Content>
</Button>
</StackPanel>
</Grid>
</AppBar>
</Page.BottomAppBar>
`
Finally found a solution. If View Box is used, that will make the page fits for all the resolutions that simulator supports, But it will affect snap view. to fix the snap view.
* Create a dedicated page for snap view.
* Check whether the app is in snap view. if yes, then navigate to another page which is dedicated for snap view.
* To unsnap, handle the windowssizechanged event of the snap view page. [if the app is in non-snap view or filled view (landscape or portrait). Navigate to original page.]