简体   繁体   English

UWP更改NavigationViewItem高度

[英]UWP change NavigationViewItem height

比较图片

On the image above, you can see my app (left) and Groove Player (right). 在上图中,您可以看到我的应用程序(左)和Groove Player(右)。 I want to make NavigationViewItem height big like Groove Player, but I don't know how. 我想使NavigationViewItem的高度像Groove Player一样大,但我不知道如何。 I tried playing with Padding and MinHeight but it doesn't look the same. 我尝试过使用Padding和MinHeight,但看起来并不一样。

I want to do the same for the AutoSuggestBox and the Settings button, that are part of NavigationView. 我要对NavigationS的一部分AutoSuggestBox和“设置”按钮执行相同的操作。

    <NavigationView x:Name="navView" IsSettingsVisible="True">
        <NavigationView.AutoSuggestBox>
            <AutoSuggestBox QueryIcon="Find" PlaceholderText="Search"></AutoSuggestBox>
        </NavigationView.AutoSuggestBox>

        <NavigationView.MenuItems>
            <NavigationViewItem x:Name="button1" Icon="Favorite" Content="Button 1" Tapped="Button1_Tapped"/>
            <NavigationViewItem x:Name="button2" Icon="Save" Content="Button 2" Tapped="Button2_Tapped"/>
        </NavigationView.MenuItems>
    </NavigationView>

UWP change NavigationViewItem height UWP更改NavigationViewItem高度

For your requirement, you could edit NavigationViewItem template. 根据您的要求,您可以编辑NavigationViewItem模板。 Right click NavigationViewItem in the xaml designer -> Edit Template -> Edit a copy. 右键单击xaml设计器中的NavigationViewItem >编辑模板->编辑副本。

在此处输入图片说明

If you want to change NavigationViewItem height, you could modify LayoutRoot height. 如果要更改NavigationViewItem高度,则可以修改LayoutRoot高度。 And then modify SelectionIndicator height correspondingly. 然后相应地修改SelectionIndicator高度。

<Grid x:Name="LayoutRoot" Background="{TemplateBinding Background}" Height="50" Control.IsTemplateFocusTarget="True">
 ......
<Rectangle x:Name="SelectionIndicator" Fill="{ThemeResource NavigationViewSelectionIndicatorForeground}" Height="40" Opacity="0.0" Width="6"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM