【问题标题】:NavigationView does not show PaneHeader when IsPaneToggleButtonVisible is false当 IsPaneToggleButtonVisible 为 false 时,NavigationView 不显示 PaneHeader
【发布时间】:2020-04-03 08:40:07
【问题描述】:

我的 UWP 应用中的 NavigationView 控件存在问题。当我将 IsPaneToggleButtonVisible 设置为 false 时,我的 PaneHeader 也会崩溃。官方的这个错误是solved,我做错了吗?

<NavigationView PaneDisplayMode="Left" IsPaneToggleButtonVisible="False" IsBackButtonVisible="Collapsed" OpenPaneLength="200" IsSettingsVisible="False" Height="923">
                            <NavigationView.PaneHeader>
                                <Image x:Name="Header" Source="/Assets/Header.png" Stretch="UniformToFill" Margin="0,0,0,0" HorizontalAlignment="Left" Width="216" Height="53"/>
                            </NavigationView.PaneHeader>
<NavigationView/>

【问题讨论】:

    标签: xaml uwp uwp-xaml navigationview


    【解决方案1】:

    基于这个thread,它提到

    此问题已在 #1083 中解决,现已成功解决 作为 Microsoft.UI.Xaml v2.2.190731001-prerelease 发布。

    这意味着该错误已在 Windows UI 库版本的 NavigationView 中解决,因此如果要显示您的 PaneHeader,您需要安装 Microsoft.UI.Xaml nuget package,然后将 &lt;XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/&gt; 添加到您的 Application.Resources。

    .App.xaml:

    <Application>
        <Application.Resources>
            <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" /> 
        </Application.Resources>
    </Application>
    

    .MainPage.xaml:

    <Page
        ......
        xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
        >
    
        <Grid>
            <muxc:NavigationView PaneDisplayMode="Left" IsPaneToggleButtonVisible="False" IsBackButtonVisible="Collapsed" OpenPaneLength="200" IsSettingsVisible="False" Height="923">
                <muxc:NavigationView.PaneHeader>
                    <Image x:Name="Header" Source="Assets/StoreLogo.png" Stretch="UniformToFill" Margin="0,0,0,0" HorizontalAlignment="Left" Width="53" Height="53"/>
                </muxc:NavigationView.PaneHeader>
            </muxc:NavigationView>
        </Grid>
    </Page>
    

    【讨论】:

      猜你喜欢
      • 2016-06-03
      • 1970-01-01
      • 1970-01-01
      • 2013-01-23
      • 2018-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多