UWP/C# 根据 NavView 模式更改控件可见性
UWP/C# Changing control visibility based on NavView Mode
我需要尝试更改基于 NavigationView 的 StackPanel 的可见性 "PaneDisplaymode"
我有以下导航视图控件和一个简单的 AppBarButton StackPanel。
我不确定是否有办法引用当前的 PanDisplayMode 然后确定 StackPanel 的可见性?
关于此的任何 guidance/help 都很棒。
<NavigationView IsSettingsVisible="False"
PaneTitle="Menu"
x:Name="NavView"
IsBackButtonVisible="Collapsed"
PaneDisplayMode="Left"
AlwaysShowHeader="True"
SelectionChanged="NavView_SelectionChanged">
<!-- All navigation view Items nested within here -->
<NavigationView.MenuItems>
<StackPanel Orientation="Horizontal" UseLayoutRounding="False" x:Name="AppBarButtons" Tag="AppBarButtonPanel"> <!--Visibility="{Binding ControlShit}"-->
<AppBarButton Icon="Page2" Margin="0, 2, 1, 0" Tag="New_Sheet" HorizontalAlignment="Center" Width="56.5" Height="56.5" ClickMode="Press" Click="NewFile_ClickAsync"/>
<AppBarButton Icon="OpenFile" Margin="1, 2, 0, 0" Tag="Open_Sheet" HorizontalAlignment="Center" Width="56.5" Height="56.5" ClickMode="Press" Click="OpenFile_Click"/>
<AppBarButton Icon="Save" Margin="1, 2, 0, 0" Tag="Save_Sheet" HorizontalAlignment="Center" Width="56.5" Height="56.5" ClickMode="Press" Click="SaveButton_ClickAsync"/>
<AppBarButton Icon="Setting" Margin="1, 2, 0, 0" Tag="Settings_Page" HorizontalAlignment="Center" Width="56.5" Height="56.5" ClickMode="Press" Click="SettingsButton_Click"/>
<AppBarButton Icon="Calculator" Margin="1, 2, 0, 0" Tag="Calculator_Open" HorizontalAlignment="Center" Width="56.5" Height="56.5" ClickMode="Press" Click="CalcButton_ClickAsync"/>
</StackPanel>
</NavigationView.MenuItems>
您可以使用PaneClosed and PaneOpened events of NavigationView to change the Visibility of your StackPanel , another way to do it would be to use DisplayModeChanged,其中您可以使用PaneDisplayMode 属性的switch语句并检查它是关闭还是打开,然后更改相应的可见性。
我需要尝试更改基于 NavigationView 的 StackPanel 的可见性 "PaneDisplaymode"
我有以下导航视图控件和一个简单的 AppBarButton StackPanel。
我不确定是否有办法引用当前的 PanDisplayMode 然后确定 StackPanel 的可见性?
关于此的任何 guidance/help 都很棒。
<NavigationView IsSettingsVisible="False"
PaneTitle="Menu"
x:Name="NavView"
IsBackButtonVisible="Collapsed"
PaneDisplayMode="Left"
AlwaysShowHeader="True"
SelectionChanged="NavView_SelectionChanged">
<!-- All navigation view Items nested within here -->
<NavigationView.MenuItems>
<StackPanel Orientation="Horizontal" UseLayoutRounding="False" x:Name="AppBarButtons" Tag="AppBarButtonPanel"> <!--Visibility="{Binding ControlShit}"-->
<AppBarButton Icon="Page2" Margin="0, 2, 1, 0" Tag="New_Sheet" HorizontalAlignment="Center" Width="56.5" Height="56.5" ClickMode="Press" Click="NewFile_ClickAsync"/>
<AppBarButton Icon="OpenFile" Margin="1, 2, 0, 0" Tag="Open_Sheet" HorizontalAlignment="Center" Width="56.5" Height="56.5" ClickMode="Press" Click="OpenFile_Click"/>
<AppBarButton Icon="Save" Margin="1, 2, 0, 0" Tag="Save_Sheet" HorizontalAlignment="Center" Width="56.5" Height="56.5" ClickMode="Press" Click="SaveButton_ClickAsync"/>
<AppBarButton Icon="Setting" Margin="1, 2, 0, 0" Tag="Settings_Page" HorizontalAlignment="Center" Width="56.5" Height="56.5" ClickMode="Press" Click="SettingsButton_Click"/>
<AppBarButton Icon="Calculator" Margin="1, 2, 0, 0" Tag="Calculator_Open" HorizontalAlignment="Center" Width="56.5" Height="56.5" ClickMode="Press" Click="CalcButton_ClickAsync"/>
</StackPanel>
</NavigationView.MenuItems>
您可以使用PaneClosed and PaneOpened events of NavigationView to change the Visibility of your StackPanel , another way to do it would be to use DisplayModeChanged,其中您可以使用PaneDisplayMode 属性的switch语句并检查它是关闭还是打开,然后更改相应的可见性。