From 3b90f73bd02559ae94524d4191b3aa6a64d92a25 Mon Sep 17 00:00:00 2001
From: Jay <65828559+Jay-o-Way@users.noreply.github.com>
Date: Wed, 3 Jan 2024 16:41:26 +0100
Subject: [PATCH] [Refactor]XAML binding improvements (#30675)
---
.../Views/MainPage.xaml | 2 +-
.../SettingsXAML/Views/AlwaysOnTopPage.xaml | 38 +++---
.../SettingsXAML/Views/AwakePage.xaml | 8 +-
.../SettingsXAML/Views/ColorPickerPage.xaml | 12 +-
.../SettingsXAML/Views/CropAndLockPage.xaml | 8 +-
.../SettingsXAML/Views/DashboardPage.xaml | 6 +-
.../Views/EnvironmentVariablesPage.xaml | 12 +-
.../SettingsXAML/Views/FancyZonesPage.xaml | 88 +++++++-------
.../SettingsXAML/Views/FileLocksmithPage.xaml | 10 +-
.../SettingsXAML/Views/GeneralPage.xaml | 102 ++++++++--------
.../SettingsXAML/Views/HostsPage.xaml | 18 +--
.../SettingsXAML/Views/ImageResizerPage.xaml | 40 +++----
.../Views/KeyboardManagerPage.xaml | 10 +-
.../SettingsXAML/Views/MeasureToolPage.xaml | 16 +--
.../SettingsXAML/Views/MouseUtilsPage.xaml | 62 +++++-----
.../Views/MouseWithoutBordersPage.xaml | 58 ++++-----
.../SettingsXAML/Views/PastePlainPage.xaml | 12 +-
.../SettingsXAML/Views/PeekPage.xaml | 18 +--
.../SettingsXAML/Views/PowerAccentPage.xaml | 24 ++--
.../SettingsXAML/Views/PowerLauncherPage.xaml | 110 +++++++++---------
.../SettingsXAML/Views/PowerOcrPage.xaml | 16 +--
.../SettingsXAML/Views/PowerPreviewPage.xaml | 92 +++++++--------
.../SettingsXAML/Views/PowerRenamePage.xaml | 28 ++---
.../Views/RegistryPreviewPage.xaml | 10 +-
.../SettingsXAML/Views/ShortcutGuidePage.xaml | 36 +++---
.../SettingsXAML/Views/VideoConference.xaml | 59 +++++-----
26 files changed, 447 insertions(+), 448 deletions(-)
diff --git a/src/modules/EnvironmentVariables/EnvironmentVariables/EnvironmentVariablesXAML/Views/MainPage.xaml b/src/modules/EnvironmentVariables/EnvironmentVariables/EnvironmentVariablesXAML/Views/MainPage.xaml
index 37ee7095fe..7f22dac332 100644
--- a/src/modules/EnvironmentVariables/EnvironmentVariables/EnvironmentVariablesXAML/Views/MainPage.xaml
+++ b/src/modules/EnvironmentVariables/EnvironmentVariables/EnvironmentVariablesXAML/Views/MainPage.xaml
@@ -209,7 +209,7 @@
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/HostsPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/HostsPage.xaml
index c79bea80ec..3b8284d334 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Views/HostsPage.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/HostsPage.xaml
@@ -15,16 +15,16 @@
+ IsEnabled="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
-
+
-
+ IsEnabled="{x:Bind ViewModel.LaunchAdministratorEnabled, Mode=OneWay}">
+
-
+
-
+
@@ -50,7 +50,7 @@
-
+
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/ImageResizerPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/ImageResizerPage.xaml
index 775f7da4cc..e57857e78f 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Views/ImageResizerPage.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/ImageResizerPage.xaml
@@ -27,18 +27,18 @@
+ IsEnabled="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
-
+
+ Visibility="{x:Bind EnableEtraBoxes, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
+ Visibility="{x:Bind EnableEtraBoxes, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
+ Text="{x:Bind Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+ SelectedIndex="{x:Bind Fit, Mode=TwoWay}">
@@ -132,21 +132,21 @@
Width="116"
Minimum="0"
SpinButtonPlacementMode="Compact"
- Value="{x:Bind Path=Width, Mode=TwoWay}" />
+ Value="{x:Bind Width, Mode=TwoWay}" />
+ Visibility="{x:Bind EnableEtraBoxes, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
+ Value="{x:Bind Height, Mode=TwoWay}" />
+ SelectedIndex="{Binding Unit, Mode=TwoWay}">
@@ -178,9 +178,9 @@
-
+
-
+
@@ -195,11 +195,11 @@
MinWidth="{StaticResource SettingActionControlMinWidth}"
Maximum="100"
Minimum="0"
- Value="{x:Bind Mode=TwoWay, Path=ViewModel.JPEGQualityLevel}" />
+ Value="{x:Bind ViewModel.JPEGQualityLevel, Mode=TwoWay}" />
-
+
@@ -207,7 +207,7 @@
-
+
@@ -219,13 +219,13 @@
-
+
+ Text="{x:Bind ViewModel.FileName, Mode=TwoWay}" />
-
+
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/KeyboardManagerPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/KeyboardManagerPage.xaml
index 764ca8fccc..19ca095034 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Views/KeyboardManagerPage.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/KeyboardManagerPage.xaml
@@ -51,7 +51,7 @@
+ IsEnabled="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
@@ -62,11 +62,11 @@
-
+
-
+
+ IsEnabled="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
-
+
@@ -41,15 +41,15 @@
-
+
@@ -61,7 +61,7 @@
MinWidth="{StaticResource SettingActionControlMinWidth}"
Maximum="255"
Minimum="0"
- Value="{x:Bind Mode=TwoWay, Path=ViewModel.PixelTolerance}" />
+ Value="{x:Bind ViewModel.PixelTolerance, Mode=TwoWay}" />
@@ -81,7 +81,7 @@
-
+
@@ -96,17 +96,17 @@
-
+
-
+
-
+
-
+
+ Value="{x:Bind ViewModel.InputTimeMs, Mode=TwoWay}" />
@@ -128,7 +128,7 @@
ScrollViewer.IsVerticalRailEnabled="True"
ScrollViewer.VerticalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollMode="Enabled"
- Text="{x:Bind Mode=TwoWay, Path=ViewModel.ExcludedApps, UpdateSourceTrigger=PropertyChanged}"
+ Text="{x:Bind ViewModel.ExcludedApps, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
TextWrapping="Wrap" />
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerLauncherPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerLauncherPage.xaml
index 73f9b0b246..825ecfb41c 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerLauncherPage.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerLauncherPage.xaml
@@ -20,17 +20,17 @@
+ IsEnabled="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
-
+
-
+
-
+
@@ -77,18 +77,18 @@
-
+
-
+
-
+
+ Value="{x:Bind ViewModel.SearchInputDelayFast, Mode=TwoWay}" />
-
+
+ Value="{x:Bind ViewModel.SearchInputDelay, Mode=TwoWay}" />
@@ -119,10 +119,10 @@
MinWidth="{StaticResource SettingActionControlMinWidth}"
Minimum="1"
SpinButtonPlacementMode="Compact"
- Value="{Binding Mode=TwoWay, Path=MaximumNumberOfResults}" />
+ Value="{x:Bind ViewModel.MaximumNumberOfResults, Mode=TwoWay}" />
-
+
@@ -131,9 +131,9 @@
x:Uid="PowerLauncher_SearchQueryTuningEnabled"
HeaderIcon="{ui:FontIcon Glyph=}"
IsExpanded="True">
-
+
-
+
+ Value="{x:Bind ViewModel.SearchClickedItemWeight, Mode=TwoWay}" />
-
-
+
+
@@ -166,7 +166,7 @@
MinWidth="320"
Margin="{StaticResource SmallTopMargin}"
ItemsSource="{Binding searchResultPreferencesOptions}"
- SelectedItem="{Binding Mode=TwoWay, Path=SelectedSearchResultPreference}"
+ SelectedItem="{x:Bind SelectedSearchResultPreference, Mode=TwoWay}"
SelectedValuePath="Item2"
DisplayMemberPath="Item1"
IsEnabled="False"
@@ -176,15 +176,15 @@
MinWidth="320"
Margin="{StaticResource SmallTopMargin}"
ItemsSource="{Binding searchTypePreferencesOptions}"
- SelectedItem="{Binding Mode=TwoWay, Path=SelectedSearchTypePreference}"
+ SelectedItem="{x:Bind SelectedSearchTypePreference, Mode=TwoWay}"
SelectedValuePath="Item2"
DisplayMemberPath="Item1"
IsEnabled="False"
/>-->
-
+
-
+
@@ -195,7 +195,7 @@
-
+
@@ -203,7 +203,7 @@
-
+
@@ -238,13 +238,13 @@
-
+
@@ -340,7 +340,7 @@
-
+
+ IsChecked="{x:Bind IsGlobal, Mode=TwoWay}">
+ Value="{x:Bind WeightBoost, Mode=TwoWay}" />
+ IsChecked="{x:Bind Value, Mode=TwoWay}" />
@@ -445,8 +445,8 @@
+ MaxLength="{x:Bind TextBoxMaxLength, Mode=OneWay}"
+ Text="{x:Bind TextValue, Mode=TwoWay}" />
+ Value="{x:Bind NumberValue, Mode=TwoWay}" />
+ IsChecked="{x:Bind Value, Mode=TwoWay}" />
+ IsEnabled="{x:Bind SecondSettingIsEnabled, Mode=OneWay}">
@@ -520,7 +520,7 @@
Margin="56,0,0,0"
Description="{x:Bind Path=DisplayDescription}"
Header="{x:Bind Path=DisplayLabel}"
- IsChecked="{x:Bind Path=Value, Mode=TwoWay}" />
+ IsChecked="{x:Bind Value, Mode=TwoWay}" />
+ IsEnabled="{x:Bind SecondSettingIsEnabled, Mode=OneWay}">
+ MaxLength="{x:Bind TextBoxMaxLength, Mode=OneWay}"
+ Text="{x:Bind TextValue, Mode=TwoWay}" />
@@ -555,7 +555,7 @@
Margin="56,0,0,0"
Description="{x:Bind Path=DisplayDescription}"
Header="{x:Bind Path=DisplayLabel}"
- IsChecked="{x:Bind Path=Value, Mode=TwoWay}" />
+ IsChecked="{x:Bind Value, Mode=TwoWay}" />
+ IsEnabled="{x:Bind SecondSettingIsEnabled, Mode=OneWay}">
+ Value="{x:Bind NumberValue, Mode=TwoWay}" />
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerOcrPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerOcrPage.xaml
index b7941ae2d5..f5f09f14d3 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerOcrPage.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerOcrPage.xaml
@@ -19,33 +19,33 @@
+ IsEnabled="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
-
+
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerPreviewPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerPreviewPage.xaml
index 1ffb2ae1e8..cd865c0a83 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerPreviewPage.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerPreviewPage.xaml
@@ -23,8 +23,8 @@
-
+ IsEnabled="{x:Bind ViewModel.IsSVGRenderEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
+
-
+ IsEnabled="{x:Bind ViewModel.IsMDRenderEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
+
-
+ IsEnabled="{x:Bind ViewModel.IsMonacoRenderEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
+
@@ -89,13 +89,13 @@
IsChecked="{x:Bind ViewModel.MonacoPreviewTryFormat, Mode=TwoWay}"
IsEnabled="{x:Bind ViewModel.MonacoRenderIsEnabled, Mode=OneWay}" />
-
+
+ Value="{x:Bind ViewModel.MonacoPreviewMaxFileSize, Mode=TwoWay}" />
@@ -103,45 +103,45 @@
-
+ IsEnabled="{x:Bind ViewModel.IsPDFRenderEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
+
-
+ IsEnabled="{x:Bind ViewModel.IsGCODERenderEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
+
-
+ IsEnabled="{x:Bind ViewModel.IsQOIRenderEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
+
@@ -161,46 +161,46 @@
-
+ IsEnabled="{x:Bind ViewModel.IsSVGThumbnailEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
+
-
+ IsEnabled="{x:Bind ViewModel.IsPDFThumbnailEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
+
-
+ IsEnabled="{x:Bind ViewModel.IsGCODEThumbnailEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
+
-
+ IsEnabled="{x:Bind ViewModel.IsSTLThumbnailEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
+
@@ -210,21 +210,21 @@
-
+ IsEnabled="{x:Bind ViewModel.IsQOIThumbnailEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
+
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerRenamePage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerRenamePage.xaml
index 912ff5b67d..3af561bb30 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerRenamePage.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/PowerRenamePage.xaml
@@ -19,24 +19,24 @@
-
+ IsEnabled="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
+
-
+
-
+
-
+
@@ -48,28 +48,28 @@
Severity="Informational" />
-
+
-
+
-
+
+ Value="{x:Bind ViewModel.MaxDispListNum, Mode=TwoWay}" />
-
+
-
+
-
+
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/RegistryPreviewPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/RegistryPreviewPage.xaml
index 7b51f324ba..02bc3b1c83 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Views/RegistryPreviewPage.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/RegistryPreviewPage.xaml
@@ -17,18 +17,18 @@
+ IsEnabled="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
-
+
-
+
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/ShortcutGuidePage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/ShortcutGuidePage.xaml
index d5a5a94a0d..9075931860 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Views/ShortcutGuidePage.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/ShortcutGuidePage.xaml
@@ -16,18 +16,18 @@
-
+ IsEnabled="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
+
-
+
-
+
@@ -36,51 +36,51 @@
+ Visibility="{x:Bind ViewModel.UseLegacyPressWinKeyBehavior, Mode=OneWay, Converter={StaticResource ReverseBoolToVisibilityConverter}}">
+ Visibility="{x:Bind ViewModel.UseLegacyPressWinKeyBehavior, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}">
+ Value="{x:Bind ViewModel.PressTime, Mode=TwoWay}" />
+ Visibility="{x:Bind ViewModel.UseLegacyPressWinKeyBehavior, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}">
+ Value="{x:Bind ViewModel.DelayTime, Mode=TwoWay}" />
-
+
-
+
@@ -92,11 +92,11 @@
MinWidth="{StaticResource SettingActionControlMinWidth}"
Maximum="100"
Minimum="0"
- Value="{x:Bind Mode=TwoWay, Path=ViewModel.OverlayOpacity}" />
+ Value="{x:Bind ViewModel.OverlayOpacity, Mode=TwoWay}" />
-
+
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/VideoConference.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/VideoConference.xaml
index f4a187b9cd..c34dac09ba 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Views/VideoConference.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/VideoConference.xaml
@@ -23,7 +23,6 @@
-
-
+ IsEnabled="{x:Bind ViewModel.IsElevated, Mode=OneWay}">
+
-
+
-
+
-
+
-
+
-
+
-
+
+ ItemsSource="{x:Bind ViewModel.MicrophoneNames, Mode=OneTime}"
+ SelectedIndex="{x:Bind ViewModel.SelectedMicrophoneIndex, Mode=TwoWay}" />
-
+
-
+
+ IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=TwoWay}"
+ ItemsSource="{x:Bind ViewModel.CameraNames, Mode=OneTime}"
+ SelectedIndex="{x:Bind ViewModel.SelectedCameraIndex, Mode=TwoWay}" />
-
+
+ Command="{x:Bind ViewModel.ClearOverlayImage, Mode=OneWay}"
+ IsEnabled="{x:Bind ViewModel.CameraImageOverlayPath, Mode=OneWay, Converter={StaticResource EmptyToBoolConverter}}" />
-
+
+ ToolTipService.ToolTip="{x:Bind ViewModel.CameraImageOverlayPath, Mode=OneWay}" />
-
+
-
+
@@ -136,13 +135,13 @@
-
+
-
+
@@ -153,9 +152,9 @@
-
+
-
+