Home > Mobile >  WinUI: How to change NavigationView.Header background color?
WinUI: How to change NavigationView.Header background color?

Time:02-25

I have a NavigationView and would like to change the header background color:

header background with arrow

I have tried:

  • Looking in generic.xaml for likely styles to override
  • Using a HeaderTemplate

Here's my code:

<NavigationView Background="Gray">
    <NavigationView.Header>
        <Border Background="Green">
            <TextBlock Text="Header"/>
        </Border>
    </NavigationView.Header>
    <Border Background="Orange">
        <TextBlock Text="Sweet content"/>
    </Border>
</NavigationView>

CodePudding user response:

Try to override the NavigationViewContentBackground theme resource:

<NavigationView Background="Gray">
    <NavigationView.Resources>
        <SolidColorBrush x:Key="NavigationViewContentBackground" Color="Red" />
    </NavigationView.Resources>
    <NavigationView.Header>
        <Border Background="Green">
            <TextBlock Text="Header"/>
        </Border>
    </NavigationView.Header>
    <Border Background="Orange">
        <TextBlock Text="Sweet content"/>
    </Border>
</NavigationView>
  • Related