<!--App Orientation States-->
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="OrientationStates">
<VisualState x:Name="Full"/>
<VisualState x:Name="Fill">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="ContentRoot">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Thickness>40,20,40,20</Thickness>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(StackPanel.Orientation)" Storyboard.TargetName="InputPanel">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Orientation>Horizontal</Orientation>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.MaxWidth)" Storyboard.TargetName="Description">
<DiscreteObjectKeyFrame KeyTime="0" Value="700">
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Portrait">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="ContentRoot">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Thickness>40,20,40,20</Thickness>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.MaxWidth)" Storyboard.TargetName="Description">
<DiscreteObjectKeyFrame KeyTime="0" Value="700">
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Snapped">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="ContentRoot">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Thickness>20,20,20,20</Thickness>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(StackPanel.Orientation)" Storyboard.TargetName="InputPanel">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Orientation>Vertical</Orientation>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.MaxWidth)" Storyboard.TargetName="Description">
<DiscreteObjectKeyFrame KeyTime="0" Value="250">
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="LegalPanel">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Thickness>0,0,10,0</Thickness>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid x:Name="ContentRoot" Background="LightPink" Margin="100,20,100,20">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- Header -->
<StackPanel x:Name="Header" Grid.Row="0">
<StackPanel Orientation="Horizontal">
</StackPanel>
<TextBlock x:Name="FeatureName" Text="Context Menu " Style="{StaticResource H1Style}" TextWrapping="Wrap" Foreground="Blue"/>
</StackPanel>
<!-- Content -->
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Grid.Row="1" ZoomMode="Disabled">
<StackPanel x:Name="ContentPanel">
<StackPanel x:Name="InputPanel" Orientation="Horizontal" HorizontalAlignment="Left">
<StackPanel>
<TextBlock Text="Options" Style="{StaticResource H2Style}"/>
<TextBlock Text="Select Items" Style="{StaticResource H3Style}"/>
<ListBox x:Name="SectionList" Margin="0,0,20,0" HorizontalAlignment="Left">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBoxItem x:Name="Section1">
<TextBlock Text="1) Show a context menu" Style="{StaticResource ListBoxTextStyle}"/>
</ListBoxItem>
<ListBoxItem x:Name="Section2">
<TextBlock Text="2) Replace a default context menu" Style="{StaticResource ListBoxTextStyle}"/>
</ListBoxItem>
</ListBox>
</StackPanel>
<StackPanel Margin="0,31,0,0" >
<TextBlock Text="Description:" Style="{StaticResource H3Style}"/>
<StackPanel x:Name="Description" MaxWidth="900">
<!-- Section 1 -->
<StackPanel x:Name="Section1Input">
<TextBlock Style="{StaticResource DescriptionTextStyle}" TextWrapping="Wrap" Text="Tap on the show context menu button to show a simple context menu. Right-click or press and hold on the attachment to show an example context menu." />
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Image x:Name="Section1Image" HorizontalAlignment="Right" Source="images/attachment.png" />
</StackPanel>
</StackPanel>
<!-- Section 2 -->
<StackPanel x:Name="Section2Input">
<TextBlock Style="{StaticResource DescriptionTextStyle}" TextWrapping="Wrap" Text="Select and right-click or tap on the selection in the below text box to show a custom context menu for text." />
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<TextBox x:Name="Section2TextBox"></TextBox>
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
<!-- Output section -->
<TextBlock Text="Output" Margin="0,25,0,20" Style="{StaticResource H2Style}"/>
<StackPanel x:Name="Output" HorizontalAlignment="Left">
<!-- Section 1-->
<StackPanel x:Name="Section1Output">
<TextBlock Style="{StaticResource DescriptionTextStyle}" x:Name="Output1Text" TextWrapping="Wrap" Text="" />
</StackPanel>
<!-- Section 2 -->
<StackPanel x:Name="Section2Output" >
<TextBlock Style="{StaticResource DescriptionTextStyle}" x:Name="Output2Text" TextWrapping="Wrap" Text="" />
</StackPanel>
</StackPanel>
</StackPanel>
</ScrollViewer>
<!-- Footer -->
<StackPanel x:Name="Footer" Grid.Row="2" Margin="0, 10, 0, 0" VerticalAlignment="Bottom">
<StackPanel>
<TextBlock Style="{StaticResource FooterStyle}" TextWrapping="Wrap"/>
</StackPanel>
<StackPanel x:Name="LegalPanel" Orientation="Horizontal" Margin="0,-15,10,0" VerticalAlignment="Top" HorizontalAlignment="Right">
<TextBlock Text="|" Style="{StaticResource SeparatorStyle}" VerticalAlignment="Center" Margin="5,0,5,0"/>
<TextBlock Text="|" Style="{StaticResource SeparatorStyle}" VerticalAlignment="Center" Margin="5,0,5,0"/>
</StackPanel>
</StackPanel>
</Grid>
</Grid>
</UserControl>
Show context menu button to show a simple context menu. Right-click or press and hold on the attachment to show an example context menu:
Select and right-click or tap on the selection in the following text box to show a custom context menu for text.