I'm having an issue with NavigationView control, where it doesn't align with the center and keeps weird spacing at the right.
My code for NavigationView is:
<NavigationView
Background="Red"
PaneDisplayMode="Top"
IsSettingsVisible="False"
Grid.Row="1"
HorizontalAlignment="Center"
IsBackButtonVisible="Collapsed"
>
<NavigationView.MenuItems>
<NavigationViewItem Content="Home" Tag="SamplePage1" Icon="Library"/>
<NavigationViewItem Content="Search" Tag="SamplePage5" Icon="Shop" />
<NavigationViewItem Content="Search" Tag="SamplePage5" Icon="Shop" />
<NavigationViewItem Content="Search" Tag="SamplePage5" Icon="Shop"/>
</NavigationView.MenuItems>
</NavigationView>
I don't think that you can stretch MenuItems
. You can avoid that right space using the FooterMenuItems
.
<NavigationView
Grid.Row="1"
HorizontalAlignment="Center"
Background="Red"
IsBackButtonVisible="Collapsed"
IsSettingsVisible="False"
PaneDisplayMode="Top">
<NavigationView.MenuItems>
<NavigationViewItem
Content="Home"
Icon="Library"
Tag="SamplePage1" />
</NavigationView.MenuItems>
<NavigationView.FooterMenuItems>
<NavigationViewItem
Content="Search"
Icon="Shop"
Tag="SamplePage5" />
<NavigationViewItem
Content="Search"
Icon="Shop"
Tag="SamplePage5" />
<NavigationViewItem
Content="Search"
Icon="Shop"
Tag="SamplePage5" />
</NavigationView.FooterMenuItems>
</NavigationView>
UPDATE
You also can override the style from generic.xaml . This is a part of it but I guess you can start to modify here.
<!-- Top nav ItemsRepeater -->
<ItemsRepeaterScrollHost
Grid.Column="3"
Grid.ColumnSpan="5">
<ScrollViewer
HorizontalScrollBarVisibility="Hidden"
HorizontalScrollMode="Disabled"
VerticalScrollBarVisibility="Hidden"
VerticalScrollMode="Disabled">
<ItemsRepeater
x:Name="TopNavMenuItemsHost"
AutomationProperties.AccessibilityView="Content"
AutomationProperties.LandmarkType="Navigation"
AutomationProperties.Name="{TemplateBinding AutomationProperties.Name}">
<ItemsRepeater.Layout>
<!--Try using UniformGridLayout instead of StackLayout-->
<!--<StackLayout Orientation="Horizontal" />-->
<UniformGridLayout
ItemsStretch="Fill"
Orientation="Horizontal" />
</ItemsRepeater.Layout>
</ItemsRepeater>
</ScrollViewer>
</ItemsRepeaterScrollHost>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.