Basically when using NavigationView, the settings item always shows up as a gear icon and a text of "Settings". Is it possible to change these two things?
Yes, you can edit the default template of the control to modify the style of the settings area. You can find the following there:
<NavigationViewItem x:Name="SettingsNavPaneItem" Grid.Row="5">
<NavigationViewItem.Icon>
<SymbolIcon Symbol="Setting"/>
</NavigationViewItem.Icon>
</NavigationViewItem>
So changing the icon is easy. Regarding the text you may be able to change it here as well, but I am not sure if the control will not override it and can't verify as I'm not at my PC. Try to use the SettingsItem
property of the NavigationView
and cast to NavigationViewItem
.
Here is how you can customize the settings item text, I don't know why I haven't thought about it before - create a custom NavigationView
and update the text manually in OnApplyTemplate
:
public class CustomizableNavigationView : NavigationView
{
protected override void OnApplyTemplate()
{
base.OnApplyTemplate();
var settingsItem = (NavigationViewItem)GetTemplateChild("SettingsNavPaneItem");
settingsItem.Content = "Custom text";
}
}
Going forward, the recommended solution will be to use the WinUI library and its NavigationView
control. This allows you to add multiple NavigatoinItem
in the PaneFooter
area and those are fully configurable. In addition to this the new control supports not only classic hamburger menu display but also can display horizontally on top of the view, which is now the recommended navigation pattern on large screens.
Using
<NavigationViewItem.Content> <TextBlock /> </NavigationViewItem.Content>
doesn't work, you were right. What you mean by your last sentence, can you give more detail of that?Sorry, didn't notice your comment. Were you able to solve this?
I still have no idea for how to change the text :(
I have updated my answer with WinUI library
NavigationView
@Xinpeng I know it is long overdue, but I have updated my answer with a proper solution for changing the text as well :-) !