uwp-shop-analytics-sample/UWPShop.Client/Views/ShellPage.xaml

126 строки
5.9 KiB
XML

<Page
x:Class="UWPShop.Client.Views.ShellPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="using:UWPShop.Client.ViewModels"
xmlns:ic="using:Microsoft.Xaml.Interactions.Core"
xmlns:i="using:Microsoft.Xaml.Interactivity"
mc:Ignorable="d">
<Page.Resources>
<DataTemplate x:Key="NavigationMenuItemDataTemplate" x:DataType="vm:ShellNavigationItem">
<Button
Margin="0"
Padding="0,9"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
Background="Transparent"
BorderThickness="0"
AutomationProperties.AccessibilityView="Control"
AutomationProperties.LandmarkType="Navigation"
AutomationProperties.Name="{x:Bind Label}"
Command="{Binding ElementName=ShellContent, Path=DataContext.ItemSelectedCommand}"
CommandParameter="{Binding}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="48" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Rectangle
Width="6"
HorizontalAlignment="Left"
VerticalAlignment="Stretch"
Fill="{ThemeResource SystemControlForegroundAccentBrush}"
Visibility="{x:Bind SelectedVis, Mode=OneWay}" />
<FontIcon
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{x:Bind SelectedForeground, Mode=OneWay}"
Glyph="{x:Bind SymbolAsChar}" />
<TextBlock
Grid.Column="1"
Margin="0,0,24,0"
VerticalAlignment="Center"
Foreground="{x:Bind SelectedForeground, Mode=OneWay}"
Text="{x:Bind Label}"
TextTrimming="CharacterEllipsis" />
</Grid>
</Button>
</DataTemplate>
</Page.Resources>
<Grid x:Name="ShellContent" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<!-- Top-level navigation menu + app content -->
<SplitView
x:Name="NavigationMenu"
Grid.RowSpan="2"
DisplayMode="{x:Bind ViewModel.DisplayMode, Mode=OneWay}"
PaneBackground="{ThemeResource SystemControlBackgroundAltHighBrush}"
IsPaneOpen="{x:Bind ViewModel.IsPaneOpen, Mode=TwoWay}">
<SplitView.Pane>
<Grid Margin="0,48,0,0">
<ScrollViewer VerticalAlignment="Stretch" TabNavigation="Local">
<Grid VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ItemsControl
VerticalAlignment="Top"
IsTabStop="False"
ItemTemplate="{StaticResource NavigationMenuItemDataTemplate}"
ItemsSource="{x:Bind ViewModel.PrimaryItems}" />
<ItemsControl
Grid.Row="1"
VerticalAlignment="Bottom"
IsTabStop="False"
ItemTemplate="{StaticResource NavigationMenuItemDataTemplate}"
ItemsSource="{x:Bind ViewModel.SecondaryItems}" />
</Grid>
</ScrollViewer>
</Grid>
</SplitView.Pane>
<Grid Background="{ThemeResource SystemControlBackgroundAltHighBrush}">
<Frame x:Name="shellFrame"/>
</Grid>
</SplitView>
<!-- Mavigation menu button -->
<Button Width="48" Height="48" BorderThickness="0" Background="Transparent" Command="{x:Bind ViewModel.OpenPaneCommand}">
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE700;" FontSize="16"/>
</Button>
<!-- Adaptive triggers -->
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="WindowStates">
<i:Interaction.Behaviors>
<ic:EventTriggerBehavior EventName="CurrentStateChanged">
<ic:InvokeCommandAction Command="{x:Bind ViewModel.StateChangedCommand}"/>
</ic:EventTriggerBehavior>
</i:Interaction.Behaviors>
<VisualState x:Name="PanoramicState">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="1024"/>
</VisualState.StateTriggers>
</VisualState>
<VisualState x:Name="WideState">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="640"/>
</VisualState.StateTriggers>
</VisualState>
<VisualState x:Name="NarrowState">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0"/>
</VisualState.StateTriggers>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</Page>