Skip to content

Commit

Permalink
Cleanup NavView tests (microsoft/microsoft-ui-xaml#2771)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinnara committed Jul 3, 2020
1 parent 77abc41 commit 58198de
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/NavigationView_TestUI/NavigationViewItemTemplatePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid Background="Plum">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<Grid.Resources>
<local:Customers x:Key="customers"/>
</Grid.Resources>
<Button AutomationProperties.Name="FocusAnchorButton">I'm just for grabbing focus</Button>
<controls:NavigationView
x:Name="NavView"
PaneDisplayMode="Top"
MenuItemsSource="{StaticResource customers}">
SelectionChanged="NavView_SelectionChanged"
MenuItemsSource="{StaticResource customers}"
Grid.Row="1">
<controls:NavigationView.MenuItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
Expand All @@ -28,6 +36,7 @@

<StackPanel Orientation="Vertical" Margin="8,0,0,0">
<Button x:Name="FlipOrientation" AutomationProperties.Name="FlipOrientationButton" Content="Flip Orientation" Click="FlipOrientation_Click"/>
<TextBlock x:Name="SelectionEventResult" AutomationProperties.Name="SelectionEventResult"></TextBlock>
</StackPanel>
</controls:NavigationView>
</Grid>
Expand Down
14 changes: 14 additions & 0 deletions test/NavigationView_TestUI/NavigationViewItemTemplatePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,19 @@ private void FlipOrientation_Click(object sender, RoutedEventArgs e)
{
NavView.PaneDisplayMode = NavView.PaneDisplayMode == NavigationViewPaneDisplayMode.Top ? NavigationViewPaneDisplayMode.Auto : NavigationViewPaneDisplayMode.Top;
}

private void NavView_SelectionChanged(ModernWpf.Controls.NavigationView sender, ModernWpf.Controls.NavigationViewSelectionChangedEventArgs args)
{
var children = (StackPanel)args.SelectedItemContainer.Content;
var customer = (Customer)args.SelectedItem;
if(children != null && customer != null)
{
SelectionEventResult.Text = "Passed";
}
else
{
SelectionEventResult.Text = "Failed";
}
}
}
}

0 comments on commit 58198de

Please sign in to comment.