Skip to content

Commit 604c5f6

Browse files
authored
Code Quality: Minor optimizations to XAML (#10964)
1 parent a51be7a commit 604c5f6

File tree

8 files changed

+18
-86
lines changed

8 files changed

+18
-86
lines changed

src/Files.App/Strings/en-US/Resources.resw

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,12 +1533,6 @@
15331533
<data name="ElevateConfirmDialog.Content" xml:space="preserve">
15341534
<value>Would you like to continue as administrator?</value>
15351535
</data>
1536-
<data name="FullTrustStatusTeachingTip.Subtitle" xml:space="preserve">
1537-
<value>Files is running as administrator</value>
1538-
</data>
1539-
<data name="FullTrustStatusTeachingTip.Title" xml:space="preserve">
1540-
<value>Administrator</value>
1541-
</data>
15421536
<data name="ColumnsShortcutTooltip" xml:space="preserve">
15431537
<value>Columns (Ctrl+Shift+6)</value>
15441538
</data>

src/Files.App/UserControls/DataGridHeader.xaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
x:Class="Files.App.UserControls.DataGridHeader"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5-
xmlns:ciao="using:CommunityToolkit.WinUI.UI"
65
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7-
xmlns:local="using:Files.App.UserControls"
86
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
97
d:DesignHeight="300"
108
d:DesignWidth="400"

src/Files.App/UserControls/FilePreviews/CodePreview.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
mc:Ignorable="d">
1313
<Border>
1414
<ScrollViewer
15-
Grid.Row="0"
1615
HorizontalScrollBarVisibility="Auto"
1716
HorizontalScrollMode="Auto">
1817
<RichTextBlock

src/Files.App/UserControls/SidebarControl.xaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
xmlns:navigationcontrolitems="using:Files.App.DataModels.NavigationControlItems"
1111
xmlns:vc="using:Files.App.ValueConverters"
1212
HorizontalAlignment="Stretch"
13-
d:DesignHeight="768"
14-
d:DesignWidth="200"
1513
Collapsed="NavigationView_Collapsed"
1614
DisplayModeChanged="SidebarControl_DisplayModeChanged"
1715
Expanding="NavigationView_Expanding"
@@ -373,7 +371,7 @@
373371
</Grid>
374372

375373
<!-- This allows the user to resize the Sidebar -->
376-
<Grid
374+
<Border
377375
x:Name="ResizeElementBorder"
378376
Grid.Row="0"
379377
Grid.RowSpan="2"
@@ -399,7 +397,7 @@
399397
IsTabStop="True"
400398
KeyDown="Border_KeyDown"
401399
UseSystemFocusVisuals="True" />
402-
</Grid>
400+
</Border>
403401

404402
<!-- This is a special spot just for tabs so that the title bar DragArea can function properly -->
405403
<Border

src/Files.App/UserControls/SidebarControl.xaml.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -986,17 +986,17 @@ private void Border_PointerExited(object sender, PointerRoutedEventArgs e)
986986
if (dragging)
987987
return; // keep showing pressed event if currently resizing the sidebar
988988

989-
((Grid)sender).ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.Arrow));
990-
VisualStateManager.GoToState(((Grid)sender).FindAscendant<SplitView>(), "ResizerNormal", true);
989+
((Border)sender).ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.Arrow));
990+
VisualStateManager.GoToState(((Border)sender).FindAscendant<SplitView>(), "ResizerNormal", true);
991991
}
992992

993993
private void Border_PointerEntered(object sender, PointerRoutedEventArgs e)
994994
{
995995
if (DisplayMode != NavigationViewDisplayMode.Expanded)
996996
return;
997997

998-
((Grid)sender).ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.SizeWestEast));
999-
VisualStateManager.GoToState(((Grid)sender).FindAscendant<SplitView>(), "ResizerPointerOver", true);
998+
((Border)sender).ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.SizeWestEast));
999+
VisualStateManager.GoToState(((Border)sender).FindAscendant<SplitView>(), "ResizerPointerOver", true);
10001000
}
10011001

10021002
private void SetSize(double val, bool closeImmediatleyOnOversize = false)
@@ -1024,8 +1024,8 @@ private void SetSize(double val, bool closeImmediatleyOnOversize = false)
10241024

10251025
private void ResizeElementBorder_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
10261026
{
1027-
((Grid)sender).ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.Arrow));
1028-
VisualStateManager.GoToState(((Grid)sender).FindAscendant<SplitView>(), "ResizerNormal", true);
1027+
((Border)sender).ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.Arrow));
1028+
VisualStateManager.GoToState(((Border)sender).FindAscendant<SplitView>(), "ResizerNormal", true);
10291029
UserSettingsService.AppearanceSettingsService.SidebarWidth = OpenPaneLength;
10301030
dragging = false;
10311031
}
@@ -1041,8 +1041,8 @@ private void ResizeElementBorder_ManipulationStarted(object sender, Manipulation
10411041
return;
10421042

10431043
originalSize = IsPaneOpen ? UserSettingsService.AppearanceSettingsService.SidebarWidth : CompactPaneLength;
1044-
((Grid)sender).ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.SizeWestEast));
1045-
VisualStateManager.GoToState(((Grid)sender).FindAscendant<SplitView>(), "ResizerPressed", true);
1044+
((Border)sender).ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.SizeWestEast));
1045+
VisualStateManager.GoToState(((Border)sender).FindAscendant<SplitView>(), "ResizerPressed", true);
10461046
dragging = true;
10471047
}
10481048

src/Files.App/UserControls/StatusBarControl.xaml

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,86 +2,38 @@
22
x:Class="Files.App.UserControls.StatusBarControl"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5-
xmlns:converters1="using:CommunityToolkit.WinUI.UI.Converters"
65
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7-
xmlns:helpers="using:Files.App.Helpers"
86
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9-
d:DesignHeight="40"
7+
d:DesignHeight="32"
108
d:DesignWidth="400"
119
mc:Ignorable="d">
12-
<UserControl.Resources>
13-
<ResourceDictionary>
14-
<SolidColorBrush x:Key="ButtonBorderBrushDisabled" Color="Transparent" />
15-
<SolidColorBrush x:Key="ButtonBackgroundDisabled" Color="Transparent" />
1610

17-
<Style
18-
x:Key="StatusBarButtonStyle"
19-
BasedOn="{StaticResource DefaultButtonStyle}"
20-
TargetType="Button">
21-
<Setter Property="Padding" Value="0" />
22-
<Setter Property="Background" Value="Transparent" />
23-
<Setter Property="BorderBrush" Value="Transparent" />
24-
<Setter Property="Width" Value="32" />
25-
<Setter Property="Height" Value="32" />
26-
</Style>
27-
</ResourceDictionary>
28-
</UserControl.Resources>
29-
30-
<Grid
11+
<StackPanel
3112
Height="32"
3213
Padding="8,0"
3314
HorizontalAlignment="Stretch"
34-
VerticalAlignment="Stretch">
35-
<Grid.ColumnDefinitions>
36-
<ColumnDefinition Width="Auto" />
37-
<ColumnDefinition Width="Auto" />
38-
<ColumnDefinition Width="Auto" />
39-
<ColumnDefinition Width="*" />
40-
<ColumnDefinition Width="Auto" />
41-
</Grid.ColumnDefinitions>
15+
VerticalAlignment="Stretch"
16+
Orientation="Horizontal"
17+
Spacing="8">
4218

4319
<TextBlock
4420
x:Name="DirectoryItemCount"
45-
Grid.Column="0"
46-
Margin="0,0,12,0"
4721
VerticalAlignment="Center"
4822
x:Load="{x:Bind ShowInfoText, Mode=OneWay}"
4923
Text="{x:Bind DirectoryPropertiesViewModel.DirectoryItemCount, Mode=OneWay}" />
24+
5025
<TextBlock
5126
x:Name="SelectedItemsCountString"
52-
Grid.Column="1"
53-
Margin="0,0,12,0"
5427
VerticalAlignment="Center"
5528
x:Load="{x:Bind ShowInfoText, Mode=OneWay}"
5629
Text="{x:Bind SelectedItemsPropertiesViewModel.SelectedItemsCountString, Mode=OneWay}"
5730
Visibility="{x:Bind SelectedItemsPropertiesViewModel.IsItemSelected, Mode=OneWay}" />
31+
5832
<TextBlock
5933
x:Name="ItemSize"
60-
Grid.Column="2"
61-
Margin="0,0,12,0"
6234
VerticalAlignment="Center"
6335
x:Load="{x:Bind ShowInfoText, Mode=OneWay}"
6436
Text="{x:Bind SelectedItemsPropertiesViewModel.ItemSize, Mode=OneWay}"
6537
Visibility="{x:Bind SelectedItemsPropertiesViewModel.ItemSizeVisibility, Mode=OneWay}" />
66-
67-
<Button
68-
x:Name="FullTrustStatus"
69-
Grid.Column="4"
70-
VerticalAlignment="Center"
71-
x:Load="{x:Bind AppModel.IsAppElevated, Mode=OneWay}"
72-
AccessKey="M"
73-
Click="FullTrustStatus_Click"
74-
FontSize="16"
75-
Style="{StaticResource StatusBarButtonStyle}">
76-
<FontIcon FontSize="14" Glyph="&#xEA18;" />
77-
</Button>
78-
79-
<TeachingTip
80-
x:Name="FullTrustStatusTeachingTip"
81-
Title="{helpers:ResourceString Name=FullTrustStatusTeachingTip/Title}"
82-
Grid.ColumnSpan="5"
83-
Subtitle="{helpers:ResourceString Name=FullTrustStatusTeachingTip/Subtitle}"
84-
Target="{x:Bind FullTrustStatus}"
85-
Visibility="Collapsed" />
86-
</Grid>
38+
</StackPanel>
8739
</UserControl>

src/Files.App/UserControls/StatusBarControl.xaml.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ namespace Files.App.UserControls
99
{
1010
public sealed partial class StatusBarControl : UserControl, INotifyPropertyChanged
1111
{
12-
public AppModel AppModel => App.AppModel;
13-
1412
public DirectoryPropertiesViewModel DirectoryPropertiesViewModel
1513
{
1614
get => (DirectoryPropertiesViewModel)GetValue(DirectoryPropertiesViewModelProperty);
@@ -45,11 +43,6 @@ public StatusBarControl()
4543
this.InitializeComponent();
4644
}
4745

48-
private void FullTrustStatus_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
49-
{
50-
FullTrustStatusTeachingTip.IsOpen = true;
51-
}
52-
5346
public event PropertyChangedEventHandler PropertyChanged;
5447

5548
private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")

src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
x:Class="Files.App.Views.LayoutModes.DetailsLayoutBrowser"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5-
xmlns:animations="using:CommunityToolkit.WinUI.UI.Animations"
6-
xmlns:behaviors="using:CommunityToolkit.WinUI.UI.Behaviors"
75
xmlns:behaviors2="using:Files.App.Behaviors"
86
xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls"
97
xmlns:converters="using:CommunityToolkit.WinUI.UI.Converters"

0 commit comments

Comments
 (0)