Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bff7f99

Browse files
authoredMay 4, 2025··
Code Quality: Improved visual states for Properties Window (#17099)
1 parent 4298e71 commit bff7f99

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed
 

‎src/Files.App/Views/Properties/MainPropertiesPage.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,5 +191,19 @@
191191

192192
</NavigationView>
193193

194+
<VisualStateManager.VisualStateGroups>
195+
<VisualStateGroup x:Name="NavigationStates">
196+
<VisualState x:Name="Narrow">
197+
<VisualState.Setters>
198+
<Setter Target="MainPropertiesWindowNavigationView.PaneDisplayMode" Value="LeftCompact" />
199+
</VisualState.Setters>
200+
</VisualState>
201+
<VisualState x:Name="Wide">
202+
<VisualState.Setters>
203+
<Setter Target="MainPropertiesWindowNavigationView.PaneDisplayMode" Value="Left" />
204+
</VisualState.Setters>
205+
</VisualState>
206+
</VisualStateGroup>
207+
</VisualStateManager.VisualStateGroups>
194208
</Grid>
195209
</vm:BasePropertiesPage>

‎src/Files.App/Views/Properties/MainPropertiesPage.xaml.cs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
// Copyright (c) Files Community
22
// Licensed under the MIT License.
33

4-
using Windows.Graphics;
54
using Files.App.ViewModels.Properties;
6-
using Microsoft.UI;
5+
using Microsoft.UI.Input;
76
using Microsoft.UI.Windowing;
87
using Microsoft.UI.Xaml;
9-
using Microsoft.UI.Xaml.Controls;
108
using Microsoft.UI.Xaml.Input;
119
using Microsoft.UI.Xaml.Navigation;
10+
using Windows.Graphics;
1211
using Windows.System;
13-
using Windows.UI;
14-
using Microsoft.UI.Input;
1512

1613
namespace Files.App.Views.Properties
1714
{
@@ -33,7 +30,7 @@ public MainPropertiesPage()
3330
FlowDirection = FlowDirection.RightToLeft;
3431
}
3532

36-
33+
3734
// Navigates to specified properties page
3835
public bool TryNavigateToPage(PropertiesNavigationViewItemType pageType)
3936
{
@@ -62,7 +59,7 @@ private void Page_Loaded(object sender, RoutedEventArgs e)
6259
Window.Closed += Window_Closed;
6360

6461
AppThemeModeService.ApplyResources();
65-
UpdatePageLayout();
62+
UpdatePageLayout(this.Width);
6663
Window.RaiseSetTitleBarDragRegion(SetTitleBarDragRegion);
6764
Window.AppWindow.Changed += AppWindow_Changed;
6865
}
@@ -74,24 +71,23 @@ private int SetTitleBarDragRegion(InputNonClientPointerSource source, SizeInt32
7471
}
7572

7673
private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
77-
=> UpdatePageLayout();
74+
=> UpdatePageLayout(e.NewSize.Width);
7875

7976
private void Page_KeyDown(object sender, KeyRoutedEventArgs e)
8077
{
8178
if (e.Key.Equals(VirtualKey.Escape))
8279
Window.Close();
8380
}
8481

85-
private void UpdatePageLayout()
82+
private void UpdatePageLayout(double pageWidth)
8683
{
87-
// NavigationView Pane Mode
88-
MainPropertiesWindowNavigationView.PaneDisplayMode =
89-
ActualWidth <= 600
90-
? NavigationViewPaneDisplayMode.LeftCompact
91-
: NavigationViewPaneDisplayMode.Left;
84+
if (pageWidth < 600)
85+
VisualStateManager.GoToState(this, "Narrow", true);
86+
else
87+
VisualStateManager.GoToState(this, "Wide", true);
9288

9389
// Collapse NavigationViewItem Content text
94-
if (ActualWidth <= 600)
90+
if (ActualWidth < 600)
9591
foreach (var item in MainPropertiesViewModel.NavigationViewItems) item.IsCompact = true;
9692
else
9793
foreach (var item in MainPropertiesViewModel.NavigationViewItems) item.IsCompact = false;

0 commit comments

Comments
 (0)
Please sign in to comment.