Skip to content

Commit ce0bfa1

Browse files
authored
Properties: Fixed Properties window crash on older systems (#1012)
1 parent cc60d8f commit ce0bfa1

File tree

3 files changed

+42
-31
lines changed

3 files changed

+42
-31
lines changed

Files/Dialogs/PropertiesDialog.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
xmlns:local2="using:Files.Helpers"
77
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
88
x:Name="PropertiesDialogMarkup"
9-
Title="Properties"
10-
CornerRadius="4"
9+
Background="Transparent"
1110
mc:Ignorable="d"
1211
RequestedTheme="{x:Bind local2:ThemeHelper.RootTheme}">
12+
<ContentDialog.Resources>
13+
<Thickness x:Key="ContentDialogPadding">0</Thickness>
14+
</ContentDialog.Resources>
1315

1416
<Frame
1517
x:Name="propertiesFrame"
16-
Width="375"
17-
Height="425"
1818
x:FieldModifier="public" />
1919
</ContentDialog>

Files/Interacts/Interaction.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace Files.Interacts
4242
{
4343
public class Interaction
4444
{
45-
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
45+
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
4646

4747
private readonly IShellPage CurrentInstance;
4848
private readonly InstanceTabsView instanceTabsView;
@@ -463,7 +463,7 @@ public void ShareItem_Click(object sender, RoutedEventArgs e)
463463
public static Dictionary<UIContext, AppWindow> AppWindows { get; set; }
464464
= new Dictionary<UIContext, AppWindow>();
465465

466-
private async void ShowProperties(object parameter)
466+
private async void ShowProperties()
467467
{
468468
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
469469
{
@@ -491,19 +491,19 @@ private async void ShowProperties(object parameter)
491491
else
492492
{
493493
App.PropertiesDialogDisplay.propertiesFrame.Tag = App.PropertiesDialogDisplay;
494-
App.PropertiesDialogDisplay.propertiesFrame.Navigate(typeof(Properties), parameter, new SuppressNavigationTransitionInfo());
494+
App.PropertiesDialogDisplay.propertiesFrame.Navigate(typeof(Properties), null, new SuppressNavigationTransitionInfo());
495495
await App.PropertiesDialogDisplay.ShowAsync(ContentDialogPlacement.Popup);
496496
}
497497
}
498498

499499
public void ShowPropertiesButton_Click(object sender, RoutedEventArgs e)
500500
{
501-
ShowProperties(App.CurrentInstance.ContentPage.SelectedItem);
501+
ShowProperties();
502502
}
503503

504504
public void ShowFolderPropertiesButton_Click(object sender, RoutedEventArgs e)
505505
{
506-
ShowProperties(App.CurrentInstance.ViewModel.CurrentFolder);
506+
ShowProperties();
507507
}
508508

509509
private async void Manager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)

Files/Views/Pages/Properties.xaml.cs

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public sealed partial class Properties : Page
2020
private static AppWindowTitleBar _TitleBar;
2121

2222
public AppWindow propWindow;
23+
2324
public ItemPropertiesViewModel ItemProperties { get; } = new ItemPropertiesViewModel();
2425

2526
public Properties()
@@ -38,13 +39,16 @@ public Properties()
3839

3940
private async void Properties_Loaded(object sender, RoutedEventArgs e)
4041
{
41-
// Collect AppWindow-specific info
42-
propWindow = Interaction.AppWindows[UIContext];
43-
// Set properties window titleBar style
44-
_TitleBar = propWindow.TitleBar;
45-
_TitleBar.ButtonBackgroundColor = Colors.Transparent;
46-
_TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
47-
App.AppSettings.UpdateThemeElements.Execute(null);
42+
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
43+
{
44+
// Collect AppWindow-specific info
45+
propWindow = Interaction.AppWindows[UIContext];
46+
// Set properties window titleBar style
47+
_TitleBar = propWindow.TitleBar;
48+
_TitleBar.ButtonBackgroundColor = Colors.Transparent;
49+
_TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
50+
App.AppSettings.UpdateThemeElements.Execute(null);
51+
}
4852

4953
if (App.CurrentInstance.ContentPage.IsItemSelected)
5054
{
@@ -123,22 +127,25 @@ private async void Properties_Loaded(object sender, RoutedEventArgs e)
123127
private void AppSettings_ThemeModeChanged(object sender, EventArgs e)
124128
{
125129
RequestedTheme = ThemeHelper.RootTheme;
126-
switch (ThemeHelper.RootTheme)
130+
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
127131
{
128-
case ElementTheme.Default:
129-
_TitleBar.ButtonHoverBackgroundColor = (Color)Application.Current.Resources["SystemBaseLowColor"];
130-
_TitleBar.ButtonForegroundColor = (Color)Application.Current.Resources["SystemBaseHighColor"];
131-
break;
132-
133-
case ElementTheme.Light:
134-
_TitleBar.ButtonHoverBackgroundColor = Color.FromArgb(51, 0, 0, 0);
135-
_TitleBar.ButtonForegroundColor = Colors.Black;
136-
break;
137-
138-
case ElementTheme.Dark:
139-
_TitleBar.ButtonHoverBackgroundColor = Color.FromArgb(51, 255, 255, 255);
140-
_TitleBar.ButtonForegroundColor = Colors.White;
141-
break;
132+
switch (ThemeHelper.RootTheme)
133+
{
134+
case ElementTheme.Default:
135+
_TitleBar.ButtonHoverBackgroundColor = (Color)Application.Current.Resources["SystemBaseLowColor"];
136+
_TitleBar.ButtonForegroundColor = (Color)Application.Current.Resources["SystemBaseHighColor"];
137+
break;
138+
139+
case ElementTheme.Light:
140+
_TitleBar.ButtonHoverBackgroundColor = Color.FromArgb(51, 0, 0, 0);
141+
_TitleBar.ButtonForegroundColor = Colors.Black;
142+
break;
143+
144+
case ElementTheme.Dark:
145+
_TitleBar.ButtonHoverBackgroundColor = Color.FromArgb(51, 255, 255, 255);
146+
_TitleBar.ButtonForegroundColor = Colors.White;
147+
break;
148+
}
142149
}
143150
}
144151

@@ -149,6 +156,10 @@ private async void Button_Click(object sender, RoutedEventArgs e)
149156
{
150157
await propWindow.CloseAsync();
151158
}
159+
else
160+
{
161+
App.PropertiesDialogDisplay.Hide();
162+
}
152163
}
153164
}
154165

0 commit comments

Comments
 (0)