Skip to content

Commit 86493f7

Browse files
authored
Merge pull request #10580 from siagupta0202/navigationwindow-fluent
Adds missing style for NavigationWindow in fluent
2 parents 9803e37 + 69afdc0 commit 86493f7

File tree

9 files changed

+304
-2
lines changed

9 files changed

+304
-2
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/ThemeManager.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Microsoft.Win32;
22
using System.Windows.Appearance;
3-
3+
using System.Windows.Navigation;
44

55
namespace System.Windows;
66

@@ -285,7 +285,14 @@ private static void ApplyStyleOnWindow(Window window, bool useLightColors)
285285
// We only apply Style on window, if the Window.Style has not already been set to avoid overriding users setting.
286286
if (window.Style == null)
287287
{
288-
window.SetResourceReference(FrameworkElement.StyleProperty, typeof(Window));
288+
if(window is NavigationWindow)
289+
{
290+
window.SetResourceReference(FrameworkElement.StyleProperty, typeof(NavigationWindow));
291+
}
292+
else
293+
{
294+
window.SetResourceReference(FrameworkElement.StyleProperty, typeof(Window));
295+
}
289296
}
290297

291298
window.SetImmersiveDarkMode(!useLightColors);

src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Resources/Theme/Dark.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,10 @@
587587
<SolidColorBrush x:Key="NavigationViewItemForegroundLeftFluent" Color="{StaticResource TextFillColorPrimary}" />
588588
<SolidColorBrush x:Key="NavigationViewItemForegroundPointerOverLeftFluent" Color="{StaticResource TextFillColorPrimary}" />
589589

590+
<!-- NavigationWindow -->
591+
<SolidColorBrush x:Key="NavigationWindowBackground" Color="{StaticResource ApplicationBackgroundColor}" />
592+
<SolidColorBrush x:Key="NavigationWindowForeground" Color="{StaticResource TextFillColorPrimary}" />
593+
590594
<!-- Page -->
591595
<SolidColorBrush x:Key="PageForeground" Color="{StaticResource TextFillColorPrimary}" />
592596
<SolidColorBrush x:Key="PageBackground" Color="{StaticResource SubtleFillColorTransparent}" />

src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Resources/Theme/HC.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,10 @@
458458
<SolidColorBrush x:Key="NavigationViewItemForegroundLeftFluent" Color="{StaticResource SystemColorWindowTextColor}" />
459459
<SolidColorBrush x:Key="NavigationViewItemForegroundPointerOverLeftFluent" Color="{StaticResource SystemColorWindowTextColor}" />
460460

461+
<!-- NavigationWindow -->
462+
<SolidColorBrush x:Key="NavigationWindowBackground" Color="{StaticResource SystemColorWindowColor}" />
463+
<SolidColorBrush x:Key="NavigationWindowForeground" Color="{StaticResource SystemColorWindowTextColor}" />
464+
461465
<!-- Page -->
462466
<SolidColorBrush x:Key="PageForeground" Color="{StaticResource SystemColorWindowTextColor}" />
463467
<SolidColorBrush x:Key="PageBackground" Color="Transparent" />

src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Resources/Theme/Light.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,10 @@
590590
<SolidColorBrush x:Key="NavigationViewItemForegroundLeftFluent" Color="{StaticResource TextFillColorPrimary}" />
591591
<SolidColorBrush x:Key="NavigationViewItemForegroundPointerOverLeftFluent" Color="{StaticResource TextFillColorPrimary}" />
592592

593+
<!-- NavigationWindow -->
594+
<SolidColorBrush x:Key="NavigationWindowBackground" Color="{StaticResource ApplicationBackgroundColor}" />
595+
<SolidColorBrush x:Key="NavigationWindowForeground" Color="{StaticResource TextFillColorPrimary}" />
596+
593597
<!-- Page -->
594598
<SolidColorBrush x:Key="PageForeground" Color="{StaticResource TextFillColorPrimary}" />
595599
<SolidColorBrush x:Key="PageBackground" Color="{StaticResource SubtleFillColorTransparent}" />
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:system="clr-namespace:System;assembly=System.Runtime"
4+
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=PresentationFramework">
5+
6+
<system:String x:Key="NavigationWindowMenuItemChevronDownGlyph">&#xE70D;</system:String>
7+
<system:String x:Key="NavigationWindowMenuItemArrowLeftGlyph">&#xE72B;</system:String>
8+
<system:String x:Key="NavigationWindowMenuItemArrowRightGlyph">&#xE72A;</system:String>
9+
10+
<ControlTemplate x:Key="NavigationWindowTemplateKey" TargetType="{x:Type NavigationWindow}">
11+
<Border
12+
Background="{TemplateBinding Background}"
13+
BorderBrush="{TemplateBinding BorderBrush}"
14+
BorderThickness="{TemplateBinding BorderThickness}">
15+
<DockPanel>
16+
<Menu
17+
Name="NavMenu"
18+
VerticalAlignment="Center"
19+
DockPanel.Dock="Top">
20+
<MenuItem
21+
Background="Transparent"
22+
BorderBrush="Transparent"
23+
Command="NavigationCommands.BrowseBack"
24+
FontFamily="{DynamicResource SymbolThemeFontFamily}"
25+
Header ="{StaticResource NavigationWindowMenuItemArrowLeftGlyph}"/>
26+
<MenuItem
27+
Background="Transparent"
28+
BorderBrush="Transparent"
29+
Command="NavigationCommands.BrowseForward"
30+
FontFamily="{DynamicResource SymbolThemeFontFamily}"
31+
Header ="{StaticResource NavigationWindowMenuItemArrowRightGlyph}"/>
32+
<Separator/>
33+
<MenuItem
34+
x:Name="Arrow"
35+
SnapsToDevicePixels="False"
36+
HorizontalAlignment="Right"
37+
VerticalAlignment="Center"
38+
ItemContainerStyle="{StaticResource FrameNavigationButtonJournalEntryStyle}"
39+
IsSubmenuOpen="{Binding Path=(MenuItem.IsSubmenuOpen),Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" >
40+
<MenuItem.Icon>
41+
<TextBlock FontFamily="{DynamicResource SymbolThemeFontFamily}" Text="{StaticResource NavigationWindowMenuItemChevronDownGlyph}" />
42+
</MenuItem.Icon>
43+
<MenuItem.ItemsSource>
44+
<MultiBinding Converter="{StaticResource JournalEntryUnifiedViewConverter}">
45+
<MultiBinding.Bindings>
46+
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(NavigationWindow.BackStack)" />
47+
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(NavigationWindow.ForwardStack)" />
48+
</MultiBinding.Bindings>
49+
</MultiBinding>
50+
</MenuItem.ItemsSource>
51+
</MenuItem>
52+
</Menu>
53+
<Grid>
54+
<AdornerDecorator>
55+
<ContentPresenter Name="PART_NavWinCP" ClipToBounds="True"/>
56+
</AdornerDecorator>
57+
<ResizeGrip
58+
x:Name="WindowResizeGrip"
59+
HorizontalAlignment="Right"
60+
VerticalAlignment="Bottom"
61+
Visibility="Collapsed"
62+
IsTabStop="False"/>
63+
</Grid>
64+
</DockPanel>
65+
</Border>
66+
<ControlTemplate.Triggers>
67+
<Trigger Property="ShowsNavigationUI" Value="False">
68+
<Setter TargetName="NavMenu" Property="Visibility" Value="Collapsed"/>
69+
</Trigger>
70+
<MultiTrigger>
71+
<MultiTrigger.Conditions>
72+
<Condition Property="Window.ResizeMode" Value="CanResizeWithGrip"/>
73+
<Condition Property="Window.WindowState" Value="Normal"/>
74+
</MultiTrigger.Conditions>
75+
<Setter TargetName="WindowResizeGrip" Property="Visibility" Value="Visible"/>
76+
</MultiTrigger>
77+
<MultiTrigger>
78+
<MultiTrigger.Conditions>
79+
<Condition Property="NavigationWindow.CanGoForward" Value="False"/>
80+
<Condition Property="NavigationWindow.CanGoBack" Value="False"/>
81+
</MultiTrigger.Conditions>
82+
<Setter TargetName="NavMenu" Property="IsEnabled" Value="False"/>
83+
</MultiTrigger>
84+
</ControlTemplate.Triggers>
85+
</ControlTemplate>
86+
87+
<Style x:Key="DefaultNavigationWindowStyle" TargetType="{x:Type NavigationWindow}">
88+
<Setter Property="Foreground" Value="{DynamicResource NavigationWindowForeground}"/>
89+
<Setter Property="Background" Value="{DynamicResource NavigationWindowBackground}"/>
90+
<Setter Property="OverridesDefaultStyle" Value="True" />
91+
<Setter Property="Template" Value="{StaticResource NavigationWindowTemplateKey}"/>
92+
</Style>
93+
94+
<Style BasedOn="{StaticResource DefaultNavigationWindowStyle}" TargetType="{x:Type NavigationWindow}"/>
95+
96+
</ResourceDictionary>

src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Themes/Fluent.Dark.xaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,9 @@
562562
<SolidColorBrush x:Key="NavigationViewItemBackgroundSelectedLeftFluent" Color="{StaticResource ControlFillColorDefault}" />
563563
<SolidColorBrush x:Key="NavigationViewItemForegroundLeftFluent" Color="{StaticResource TextFillColorPrimary}" />
564564
<SolidColorBrush x:Key="NavigationViewItemForegroundPointerOverLeftFluent" Color="{StaticResource TextFillColorPrimary}" />
565+
<!-- NavigationWindow -->
566+
<SolidColorBrush x:Key="NavigationWindowBackground" Color="{StaticResource ApplicationBackgroundColor}" />
567+
<SolidColorBrush x:Key="NavigationWindowForeground" Color="{StaticResource TextFillColorPrimary}" />
565568
<!-- Page -->
566569
<SolidColorBrush x:Key="PageForeground" Color="{StaticResource TextFillColorPrimary}" />
567570
<SolidColorBrush x:Key="PageBackground" Color="{StaticResource SubtleFillColorTransparent}" />
@@ -3405,6 +3408,65 @@
34053408
</Style.Triggers>
34063409
</Style>
34073410
<Style BasedOn="{StaticResource DefaultMenuItemStyle}" TargetType="{x:Type MenuItem}" />
3411+
<system:String x:Key="NavigationWindowMenuItemChevronDownGlyph"></system:String>
3412+
<system:String x:Key="NavigationWindowMenuItemArrowLeftGlyph"></system:String>
3413+
<system:String x:Key="NavigationWindowMenuItemArrowRightGlyph"></system:String>
3414+
<ControlTemplate x:Key="NavigationWindowTemplateKey" TargetType="{x:Type NavigationWindow}">
3415+
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
3416+
<DockPanel>
3417+
<Menu Name="NavMenu" VerticalAlignment="Center" DockPanel.Dock="Top">
3418+
<MenuItem Background="Transparent" BorderBrush="Transparent" Command="NavigationCommands.BrowseBack" FontFamily="{DynamicResource SymbolThemeFontFamily}" Header="{StaticResource NavigationWindowMenuItemArrowLeftGlyph}" />
3419+
<MenuItem Background="Transparent" BorderBrush="Transparent" Command="NavigationCommands.BrowseForward" FontFamily="{DynamicResource SymbolThemeFontFamily}" Header="{StaticResource NavigationWindowMenuItemArrowRightGlyph}" />
3420+
<Separator />
3421+
<MenuItem x:Name="Arrow" SnapsToDevicePixels="False" HorizontalAlignment="Right" VerticalAlignment="Center" ItemContainerStyle="{StaticResource FrameNavigationButtonJournalEntryStyle}" IsSubmenuOpen="{Binding Path=(MenuItem.IsSubmenuOpen),Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}">
3422+
<MenuItem.Icon>
3423+
<TextBlock FontFamily="{DynamicResource SymbolThemeFontFamily}" Text="{StaticResource NavigationWindowMenuItemChevronDownGlyph}" />
3424+
</MenuItem.Icon>
3425+
<MenuItem.ItemsSource>
3426+
<MultiBinding Converter="{StaticResource JournalEntryUnifiedViewConverter}">
3427+
<MultiBinding.Bindings>
3428+
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(NavigationWindow.BackStack)" />
3429+
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(NavigationWindow.ForwardStack)" />
3430+
</MultiBinding.Bindings>
3431+
</MultiBinding>
3432+
</MenuItem.ItemsSource>
3433+
</MenuItem>
3434+
</Menu>
3435+
<Grid>
3436+
<AdornerDecorator>
3437+
<ContentPresenter Name="PART_NavWinCP" ClipToBounds="True" />
3438+
</AdornerDecorator>
3439+
<ResizeGrip x:Name="WindowResizeGrip" HorizontalAlignment="Right" VerticalAlignment="Bottom" Visibility="Collapsed" IsTabStop="False" />
3440+
</Grid>
3441+
</DockPanel>
3442+
</Border>
3443+
<ControlTemplate.Triggers>
3444+
<Trigger Property="ShowsNavigationUI" Value="False">
3445+
<Setter TargetName="NavMenu" Property="Visibility" Value="Collapsed" />
3446+
</Trigger>
3447+
<MultiTrigger>
3448+
<MultiTrigger.Conditions>
3449+
<Condition Property="Window.ResizeMode" Value="CanResizeWithGrip" />
3450+
<Condition Property="Window.WindowState" Value="Normal" />
3451+
</MultiTrigger.Conditions>
3452+
<Setter TargetName="WindowResizeGrip" Property="Visibility" Value="Visible" />
3453+
</MultiTrigger>
3454+
<MultiTrigger>
3455+
<MultiTrigger.Conditions>
3456+
<Condition Property="NavigationWindow.CanGoForward" Value="False" />
3457+
<Condition Property="NavigationWindow.CanGoBack" Value="False" />
3458+
</MultiTrigger.Conditions>
3459+
<Setter TargetName="NavMenu" Property="IsEnabled" Value="False" />
3460+
</MultiTrigger>
3461+
</ControlTemplate.Triggers>
3462+
</ControlTemplate>
3463+
<Style x:Key="DefaultNavigationWindowStyle" TargetType="{x:Type NavigationWindow}">
3464+
<Setter Property="Foreground" Value="{DynamicResource NavigationWindowForeground}" />
3465+
<Setter Property="Background" Value="{DynamicResource NavigationWindowBackground}" />
3466+
<Setter Property="OverridesDefaultStyle" Value="True" />
3467+
<Setter Property="Template" Value="{StaticResource NavigationWindowTemplateKey}" />
3468+
</Style>
3469+
<Style BasedOn="{StaticResource DefaultNavigationWindowStyle}" TargetType="{x:Type NavigationWindow}" />
34083470
<Style x:Key="DefaultPageStyle" TargetType="{x:Type Page}">
34093471
<Setter Property="Foreground" Value="{DynamicResource PageForeground}" />
34103472
<Setter Property="Background" Value="{DynamicResource PageBackground}" />

src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Themes/Fluent.HC.xaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,9 @@
457457
<SolidColorBrush x:Key="NavigationViewItemBackgroundSelectedLeftFluent" Color="{StaticResource SystemColorWindowColor}" />
458458
<SolidColorBrush x:Key="NavigationViewItemForegroundLeftFluent" Color="{StaticResource SystemColorWindowTextColor}" />
459459
<SolidColorBrush x:Key="NavigationViewItemForegroundPointerOverLeftFluent" Color="{StaticResource SystemColorWindowTextColor}" />
460+
<!-- NavigationWindow -->
461+
<SolidColorBrush x:Key="NavigationWindowBackground" Color="{StaticResource SystemColorWindowColor}" />
462+
<SolidColorBrush x:Key="NavigationWindowForeground" Color="{StaticResource SystemColorWindowTextColor}" />
460463
<!-- Page -->
461464
<SolidColorBrush x:Key="PageForeground" Color="{StaticResource SystemColorWindowTextColor}" />
462465
<SolidColorBrush x:Key="PageBackground" Color="Transparent" />
@@ -3383,6 +3386,65 @@
33833386
</Style.Triggers>
33843387
</Style>
33853388
<Style BasedOn="{StaticResource DefaultMenuItemStyle}" TargetType="{x:Type MenuItem}" />
3389+
<system:String x:Key="NavigationWindowMenuItemChevronDownGlyph"></system:String>
3390+
<system:String x:Key="NavigationWindowMenuItemArrowLeftGlyph"></system:String>
3391+
<system:String x:Key="NavigationWindowMenuItemArrowRightGlyph"></system:String>
3392+
<ControlTemplate x:Key="NavigationWindowTemplateKey" TargetType="{x:Type NavigationWindow}">
3393+
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
3394+
<DockPanel>
3395+
<Menu Name="NavMenu" VerticalAlignment="Center" DockPanel.Dock="Top">
3396+
<MenuItem Background="Transparent" BorderBrush="Transparent" Command="NavigationCommands.BrowseBack" FontFamily="{DynamicResource SymbolThemeFontFamily}" Header="{StaticResource NavigationWindowMenuItemArrowLeftGlyph}" />
3397+
<MenuItem Background="Transparent" BorderBrush="Transparent" Command="NavigationCommands.BrowseForward" FontFamily="{DynamicResource SymbolThemeFontFamily}" Header="{StaticResource NavigationWindowMenuItemArrowRightGlyph}" />
3398+
<Separator />
3399+
<MenuItem x:Name="Arrow" SnapsToDevicePixels="False" HorizontalAlignment="Right" VerticalAlignment="Center" ItemContainerStyle="{StaticResource FrameNavigationButtonJournalEntryStyle}" IsSubmenuOpen="{Binding Path=(MenuItem.IsSubmenuOpen),Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}">
3400+
<MenuItem.Icon>
3401+
<TextBlock FontFamily="{DynamicResource SymbolThemeFontFamily}" Text="{StaticResource NavigationWindowMenuItemChevronDownGlyph}" />
3402+
</MenuItem.Icon>
3403+
<MenuItem.ItemsSource>
3404+
<MultiBinding Converter="{StaticResource JournalEntryUnifiedViewConverter}">
3405+
<MultiBinding.Bindings>
3406+
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(NavigationWindow.BackStack)" />
3407+
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(NavigationWindow.ForwardStack)" />
3408+
</MultiBinding.Bindings>
3409+
</MultiBinding>
3410+
</MenuItem.ItemsSource>
3411+
</MenuItem>
3412+
</Menu>
3413+
<Grid>
3414+
<AdornerDecorator>
3415+
<ContentPresenter Name="PART_NavWinCP" ClipToBounds="True" />
3416+
</AdornerDecorator>
3417+
<ResizeGrip x:Name="WindowResizeGrip" HorizontalAlignment="Right" VerticalAlignment="Bottom" Visibility="Collapsed" IsTabStop="False" />
3418+
</Grid>
3419+
</DockPanel>
3420+
</Border>
3421+
<ControlTemplate.Triggers>
3422+
<Trigger Property="ShowsNavigationUI" Value="False">
3423+
<Setter TargetName="NavMenu" Property="Visibility" Value="Collapsed" />
3424+
</Trigger>
3425+
<MultiTrigger>
3426+
<MultiTrigger.Conditions>
3427+
<Condition Property="Window.ResizeMode" Value="CanResizeWithGrip" />
3428+
<Condition Property="Window.WindowState" Value="Normal" />
3429+
</MultiTrigger.Conditions>
3430+
<Setter TargetName="WindowResizeGrip" Property="Visibility" Value="Visible" />
3431+
</MultiTrigger>
3432+
<MultiTrigger>
3433+
<MultiTrigger.Conditions>
3434+
<Condition Property="NavigationWindow.CanGoForward" Value="False" />
3435+
<Condition Property="NavigationWindow.CanGoBack" Value="False" />
3436+
</MultiTrigger.Conditions>
3437+
<Setter TargetName="NavMenu" Property="IsEnabled" Value="False" />
3438+
</MultiTrigger>
3439+
</ControlTemplate.Triggers>
3440+
</ControlTemplate>
3441+
<Style x:Key="DefaultNavigationWindowStyle" TargetType="{x:Type NavigationWindow}">
3442+
<Setter Property="Foreground" Value="{DynamicResource NavigationWindowForeground}" />
3443+
<Setter Property="Background" Value="{DynamicResource NavigationWindowBackground}" />
3444+
<Setter Property="OverridesDefaultStyle" Value="True" />
3445+
<Setter Property="Template" Value="{StaticResource NavigationWindowTemplateKey}" />
3446+
</Style>
3447+
<Style BasedOn="{StaticResource DefaultNavigationWindowStyle}" TargetType="{x:Type NavigationWindow}" />
33863448
<Style x:Key="DefaultPageStyle" TargetType="{x:Type Page}">
33873449
<Setter Property="Foreground" Value="{DynamicResource PageForeground}" />
33883450
<Setter Property="Background" Value="{DynamicResource PageBackground}" />

0 commit comments

Comments
 (0)