[Refactor]XAML binding improvements (#30675)

This commit is contained in:
Jay
2024-01-03 16:41:26 +01:00
committed by GitHub
parent b1bb27f35f
commit 3b90f73bd0
26 changed files with 447 additions and 448 deletions

View File

@@ -20,17 +20,17 @@
<controls:SettingsCard
x:Uid="PowerLauncher_EnablePowerLauncher"
HeaderIcon="{ui:BitmapIcon Source=/Assets/Settings/FluentIcons/FluentIconsPowerToysRun.png}"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabledGpoConfigured, Converter={StaticResource BoolNegationConverter}}">
IsEnabled="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}">
<ToggleSwitch x:Uid="ToggleSwitch" IsOn="{x:Bind ViewModel.EnablePowerLauncher, Mode=TwoWay}" />
</controls:SettingsCard>
<InfoBar
x:Uid="GPO_IsSettingForced"
IsClosable="False"
IsOpen="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabledGpoConfigured}"
IsTabStop="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabledGpoConfigured}"
IsOpen="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay}"
IsTabStop="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay}"
Severity="Informational" />
<custom:SettingsGroup x:Uid="Shortcut" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}">
<custom:SettingsGroup x:Uid="Shortcut" IsEnabled="{x:Bind ViewModel.EnablePowerLauncher, Mode=OneWay}">
<controls:SettingsExpander
x:Uid="Activation_Shortcut"
HeaderIcon="{ui:FontIcon Glyph=&#xEDA7;}"
@@ -38,10 +38,10 @@
<custom:ShortcutControl MinWidth="{StaticResource SettingActionControlMinWidth}" HotkeySettings="{x:Bind Path=ViewModel.OpenPowerLauncher, Mode=TwoWay}" />
<controls:SettingsExpander.Items>
<controls:SettingsCard ContentAlignment="Left">
<custom:CheckBoxWithDescriptionControl x:Uid="PowerLauncher_UseCentralizedKeyboardHook" IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.UseCentralizedKeyboardHook}" />
<custom:CheckBoxWithDescriptionControl x:Uid="PowerLauncher_UseCentralizedKeyboardHook" IsChecked="{x:Bind ViewModel.UseCentralizedKeyboardHook, Mode=TwoWay}" />
</controls:SettingsCard>
<controls:SettingsCard ContentAlignment="Left">
<CheckBox x:Uid="PowerLauncher_IgnoreHotkeysInFullScreen" IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.IgnoreHotkeysInFullScreen}" />
<CheckBox x:Uid="PowerLauncher_IgnoreHotkeysInFullScreen" IsChecked="{x:Bind ViewModel.IgnoreHotkeysInFullScreen, Mode=TwoWay}" />
</controls:SettingsCard>
</controls:SettingsExpander.Items>
</controls:SettingsExpander>
@@ -77,18 +77,18 @@
<!--<CheckBox x:Uid="PowerLauncher_OverrideWinSKey"
Margin="{StaticResource SmallTopMargin}"
IsChecked="{Binding Mode=TwoWay, Path=ViewModel.OverrideWinSKey}"
IsChecked="{x:Bind ViewModel.OverrideWinSKey, Mode=TwoWay}"
IsEnabled="False"
/>-->
<custom:SettingsGroup x:Uid="PowerLauncher_SearchResults" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}">
<custom:SettingsGroup x:Uid="PowerLauncher_SearchResults" IsEnabled="{x:Bind ViewModel.EnablePowerLauncher, Mode=OneWay}">
<controls:SettingsExpander
x:Uid="PowerLauncher_SearchQueryResultsWithDelay"
HeaderIcon="{ui:FontIcon Glyph=&#xec48;}"
IsExpanded="True">
<ToggleSwitch IsOn="{x:Bind Mode=TwoWay, Path=ViewModel.SearchQueryResultsWithDelay}" />
<ToggleSwitch IsOn="{x:Bind ViewModel.SearchQueryResultsWithDelay, Mode=TwoWay}" />
<controls:SettingsExpander.Items>
<controls:SettingsCard x:Uid="PowerLauncher_FastSearchInputDelayMs" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.SearchQueryResultsWithDelay}">
<controls:SettingsCard x:Uid="PowerLauncher_FastSearchInputDelayMs" IsEnabled="{x:Bind ViewModel.SearchQueryResultsWithDelay, Mode=OneWay}">
<NumberBox
MinWidth="{StaticResource SettingActionControlMinWidth}"
LargeChange="50"
@@ -96,9 +96,9 @@
Minimum="0"
SmallChange="10"
SpinButtonPlacementMode="Compact"
Value="{x:Bind Mode=TwoWay, Path=ViewModel.SearchInputDelayFast}" />
Value="{x:Bind ViewModel.SearchInputDelayFast, Mode=TwoWay}" />
</controls:SettingsCard>
<controls:SettingsCard x:Uid="PowerLauncher_SlowSearchInputDelayMs" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.SearchQueryResultsWithDelay}">
<controls:SettingsCard x:Uid="PowerLauncher_SlowSearchInputDelayMs" IsEnabled="{x:Bind ViewModel.SearchQueryResultsWithDelay, Mode=OneWay}">
<NumberBox
MinWidth="{StaticResource SettingActionControlMinWidth}"
LargeChange="50"
@@ -106,7 +106,7 @@
Minimum="0"
SmallChange="10"
SpinButtonPlacementMode="Compact"
Value="{x:Bind Mode=TwoWay, Path=ViewModel.SearchInputDelay}" />
Value="{x:Bind ViewModel.SearchInputDelay, Mode=TwoWay}" />
</controls:SettingsCard>
</controls:SettingsExpander.Items>
</controls:SettingsExpander>
@@ -119,10 +119,10 @@
MinWidth="{StaticResource SettingActionControlMinWidth}"
Minimum="1"
SpinButtonPlacementMode="Compact"
Value="{Binding Mode=TwoWay, Path=MaximumNumberOfResults}" />
Value="{x:Bind ViewModel.MaximumNumberOfResults, Mode=TwoWay}" />
<controls:SettingsExpander.Items>
<controls:SettingsCard ContentAlignment="Left">
<CheckBox x:Uid="PowerLauncher_ClearInputOnLaunch" IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.ClearInputOnLaunch}" />
<CheckBox x:Uid="PowerLauncher_ClearInputOnLaunch" IsChecked="{x:Bind ViewModel.ClearInputOnLaunch, Mode=TwoWay}" />
</controls:SettingsCard>
</controls:SettingsExpander.Items>
</controls:SettingsExpander>
@@ -131,9 +131,9 @@
x:Uid="PowerLauncher_SearchQueryTuningEnabled"
HeaderIcon="{ui:FontIcon Glyph=&#xE8CB;}"
IsExpanded="True">
<ToggleSwitch IsOn="{x:Bind Mode=TwoWay, Path=ViewModel.SearchQueryTuningEnabled}" />
<ToggleSwitch IsOn="{x:Bind ViewModel.SearchQueryTuningEnabled, Mode=TwoWay}" />
<controls:SettingsExpander.Items>
<controls:SettingsCard x:Uid="PowerLauncher_SearchClickedItemWeight" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.SearchQueryTuningEnabled}">
<controls:SettingsCard x:Uid="PowerLauncher_SearchClickedItemWeight" IsEnabled="{x:Bind ViewModel.SearchQueryTuningEnabled, Mode=OneWay}">
<NumberBox
MinWidth="{StaticResource SettingActionControlMinWidth}"
LargeChange="50"
@@ -141,10 +141,10 @@
Minimum="0"
SmallChange="5"
SpinButtonPlacementMode="Compact"
Value="{x:Bind Mode=TwoWay, Path=ViewModel.SearchClickedItemWeight}" />
Value="{x:Bind ViewModel.SearchClickedItemWeight, Mode=TwoWay}" />
</controls:SettingsCard>
<controls:SettingsCard ContentAlignment="Left" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.SearchQueryTuningEnabled}">
<custom:CheckBoxWithDescriptionControl x:Uid="PowerLauncher_WaitForSlowResults" IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.SearchWaitForSlowResults}" />
<controls:SettingsCard ContentAlignment="Left" IsEnabled="{x:Bind ViewModel.SearchQueryTuningEnabled, Mode=OneWay}">
<custom:CheckBoxWithDescriptionControl x:Uid="PowerLauncher_WaitForSlowResults" IsChecked="{x:Bind ViewModel.SearchWaitForSlowResults, Mode=TwoWay}" />
</controls:SettingsCard>
</controls:SettingsExpander.Items>
</controls:SettingsExpander>
@@ -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"
/>-->
<custom:SettingsGroup x:Uid="Run_PositionAppearance_GroupSettings" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}">
<custom:SettingsGroup x:Uid="Run_PositionAppearance_GroupSettings" IsEnabled="{x:Bind ViewModel.EnablePowerLauncher, Mode=OneWay}">
<controls:SettingsCard x:Uid="Run_PositionHeader" HeaderIcon="{ui:FontIcon Glyph=&#xe78b;}">
<ComboBox MinWidth="{StaticResource SettingActionControlMinWidth}" SelectedIndex="{x:Bind Mode=TwoWay, Path=ViewModel.MonitorPositionIndex}">
<ComboBox MinWidth="{StaticResource SettingActionControlMinWidth}" SelectedIndex="{x:Bind ViewModel.MonitorPositionIndex, Mode=TwoWay}">
<ComboBoxItem x:Uid="Run_Radio_Position_Cursor" />
<ComboBoxItem x:Uid="Run_Radio_Position_Primary_Monitor" />
<ComboBoxItem x:Uid="Run_Radio_Position_Focus" />
@@ -195,7 +195,7 @@
<controls:SettingsCard.Description>
<HyperlinkButton x:Uid="Windows_Color_Settings" Click="OpenColorsSettings_Click" />
</controls:SettingsCard.Description>
<ComboBox MinWidth="{StaticResource SettingActionControlMinWidth}" SelectedIndex="{x:Bind Mode=TwoWay, Path=ViewModel.ThemeIndex}">
<ComboBox MinWidth="{StaticResource SettingActionControlMinWidth}" SelectedIndex="{x:Bind ViewModel.ThemeIndex, Mode=TwoWay}">
<ComboBoxItem x:Uid="Radio_Theme_Dark" />
<ComboBoxItem x:Uid="Radio_Theme_Light" />
<ComboBoxItem x:Uid="Radio_Theme_Default" />
@@ -203,7 +203,7 @@
</controls:SettingsCard>
<controls:SettingsCard x:Uid="PowerLauncher_ShowPluginKeywords" HeaderIcon="{ui:FontIcon Glyph=&#xE8FD;}">
<ComboBox MinWidth="{StaticResource SettingActionControlMinWidth}" SelectedIndex="{x:Bind Mode=TwoWay, Path=ViewModel.ShowPluginsOverviewIndex}">
<ComboBox MinWidth="{StaticResource SettingActionControlMinWidth}" SelectedIndex="{x:Bind ViewModel.ShowPluginsOverviewIndex, Mode=TwoWay}">
<ComboBoxItem x:Uid="ShowPluginsOverview_All" />
<ComboBoxItem x:Uid="ShowPluginsOverview_NonGlobal" />
<ComboBoxItem x:Uid="ShowPluginsOverview_None" />
@@ -238,13 +238,13 @@
</controls:SettingsCard>
</custom:SettingsGroup>
<custom:SettingsGroup x:Uid="PowerLauncher_Plugins" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}">
<custom:SettingsGroup x:Uid="PowerLauncher_Plugins" IsEnabled="{x:Bind ViewModel.EnablePowerLauncher, Mode=OneWay}">
<InfoBar
x:Uid="Run_ConflictingKeywordInfo"
IsClosable="False"
IsOpen="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}"
IsTabStop="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}"
IsOpen="{x:Bind ViewModel.EnablePowerLauncher, Mode=OneWay}"
IsTabStop="{x:Bind ViewModel.EnablePowerLauncher, Mode=OneWay}"
Severity="Informational">
<InfoBar.ActionButton>
<HyperlinkButton x:Uid="Run_ConflictingKeywordInfo_Link" NavigateUri="https://aka.ms/PowerToysOverview_PowerToysRun#direct-activation-commands" />
@@ -340,7 +340,7 @@
</StackPanel>
<controls:SettingsExpander.Items>
<controls:SettingsCard x:Uid="PowerLauncher_ActionKeyword" IsEnabled="{x:Bind Enabled, Mode=OneWay}">
<TextBox MinWidth="{StaticResource SettingActionControlMinWidth}" Text="{x:Bind Path=ActionKeyword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<TextBox MinWidth="{StaticResource SettingActionControlMinWidth}" Text="{x:Bind ActionKeyword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</controls:SettingsCard>
<controls:SettingsCard
Padding="0,-4,0,0"
@@ -362,7 +362,7 @@
<CheckBox
Margin="0,-8,0,0"
AutomationProperties.Name="{Binding ElementName=IncludeInGlobalResultTitle, Path=Text}"
IsChecked="{x:Bind Path=IsGlobal, Mode=TwoWay}">
IsChecked="{x:Bind IsGlobal, Mode=TwoWay}">
<StackPanel Orientation="Vertical">
<TextBlock x:Name="IncludeInGlobalResultTitle" x:Uid="PowerLauncher_IncludeInGlobalResultTitle" />
<custom:IsEnabledTextBlock
@@ -380,7 +380,7 @@
Minimum="-1000"
SmallChange="10"
SpinButtonPlacementMode="Compact"
Value="{x:Bind Mode=TwoWay, Path=WeightBoost}" />
Value="{x:Bind WeightBoost, Mode=TwoWay}" />
</controls:SettingsCard>
<controls:SettingsCard
MinHeight="0"
@@ -413,7 +413,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}" />
</controls:SettingsCard>
<!-- ComboBox setting -->
<controls:SettingsCard
@@ -429,7 +429,7 @@
MinWidth="{StaticResource SettingActionControlMinWidth}"
DisplayMemberPath="Key"
ItemsSource="{x:Bind Path=ComboBoxItems}"
SelectedValue="{x:Bind Path=ComboBoxValue, Mode=TwoWay}"
SelectedValue="{x:Bind ComboBoxValue, Mode=TwoWay}"
SelectedValuePath="Value" />
</controls:SettingsCard>
<!-- TextBox setting -->
@@ -445,8 +445,8 @@
<TextBox
MinWidth="{StaticResource SettingActionControlMinWidth}"
MaxWidth="450"
MaxLength="{x:Bind Path=TextBoxMaxLength, Mode=OneWay}"
Text="{x:Bind Path=TextValue, Mode=TwoWay}" />
MaxLength="{x:Bind TextBoxMaxLength, Mode=OneWay}"
Text="{x:Bind TextValue, Mode=TwoWay}" />
</controls:SettingsCard>
<!-- NumberBox setting -->
<controls:SettingsCard
@@ -460,12 +460,12 @@
Visibility="{x:Bind Path=ShowNumberBox, Converter={StaticResource BoolToVisibilityConverter}}">
<NumberBox
MinWidth="{StaticResource SettingActionControlMinWidth}"
LargeChange="{x:Bind Path=NumberBoxLargeChange, Mode=OneWay}"
Maximum="{x:Bind Path=NumberBoxMax, Mode=OneWay}"
Minimum="{x:Bind Path=NumberBoxMin, Mode=OneWay}"
SmallChange="{x:Bind Path=NumberBoxSmallChange, Mode=OneWay}"
LargeChange="{x:Bind NumberBoxLargeChange, Mode=OneWay}"
Maximum="{x:Bind NumberBoxMax, Mode=OneWay}"
Minimum="{x:Bind NumberBoxMin, Mode=OneWay}"
SmallChange="{x:Bind NumberBoxSmallChange, Mode=OneWay}"
SpinButtonPlacementMode="Compact"
Value="{x:Bind Path=NumberValue, Mode=TwoWay}" />
Value="{x:Bind NumberValue, Mode=TwoWay}" />
</controls:SettingsCard>
<!-- Checkbox And ComboBox setting -->
<StackPanel
@@ -484,7 +484,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}" />
</controls:SettingsCard>
<controls:SettingsCard
MinHeight="0"
@@ -494,12 +494,12 @@
CornerRadius="0"
Description="{x:Bind Path=SecondDisplayDescription}"
Header="{x:Bind Path=SecondDisplayLabel}"
IsEnabled="{x:Bind Path=SecondSettingIsEnabled, Mode=OneWay}">
IsEnabled="{x:Bind SecondSettingIsEnabled, Mode=OneWay}">
<ComboBox
MinWidth="{StaticResource SettingActionControlMinWidth}"
DisplayMemberPath="Key"
ItemsSource="{x:Bind Path=ComboBoxItems}"
SelectedValue="{x:Bind Path=ComboBoxValue, Mode=TwoWay}"
SelectedValue="{x:Bind ComboBoxValue, Mode=TwoWay}"
SelectedValuePath="Value" />
</controls:SettingsCard>
</StackPanel>
@@ -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}" />
</controls:SettingsCard>
<controls:SettingsCard
MinHeight="0"
@@ -530,12 +530,12 @@
CornerRadius="0"
Description="{x:Bind Path=SecondDisplayDescription}"
Header="{x:Bind Path=SecondDisplayLabel}"
IsEnabled="{x:Bind Path=SecondSettingIsEnabled, Mode=OneWay}">
IsEnabled="{x:Bind SecondSettingIsEnabled, Mode=OneWay}">
<TextBox
MinWidth="{StaticResource SettingActionControlMinWidth}"
MaxWidth="450"
MaxLength="{x:Bind Path=TextBoxMaxLength, Mode=OneWay}"
Text="{x:Bind Path=TextValue, Mode=TwoWay}" />
MaxLength="{x:Bind TextBoxMaxLength, Mode=OneWay}"
Text="{x:Bind TextValue, Mode=TwoWay}" />
</controls:SettingsCard>
</StackPanel>
<!-- Checkbox And NumberBox setting -->
@@ -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}" />
</controls:SettingsCard>
<controls:SettingsCard
MinHeight="0"
@@ -565,15 +565,15 @@
CornerRadius="0"
Description="{x:Bind Path=SecondDisplayDescription}"
Header="{x:Bind Path=SecondDisplayLabel}"
IsEnabled="{x:Bind Path=SecondSettingIsEnabled, Mode=OneWay}">
IsEnabled="{x:Bind SecondSettingIsEnabled, Mode=OneWay}">
<NumberBox
MinWidth="{StaticResource SettingActionControlMinWidth}"
LargeChange="{x:Bind Path=NumberBoxLargeChange, Mode=OneWay}"
Maximum="{x:Bind Path=NumberBoxMax, Mode=OneWay}"
Minimum="{x:Bind Path=NumberBoxMin, Mode=OneWay}"
SmallChange="{x:Bind Path=NumberBoxSmallChange, Mode=OneWay}"
LargeChange="{x:Bind NumberBoxLargeChange, Mode=OneWay}"
Maximum="{x:Bind NumberBoxMax, Mode=OneWay}"
Minimum="{x:Bind NumberBoxMin, Mode=OneWay}"
SmallChange="{x:Bind NumberBoxSmallChange, Mode=OneWay}"
SpinButtonPlacementMode="Compact"
Value="{x:Bind Path=NumberValue, Mode=TwoWay}" />
Value="{x:Bind NumberValue, Mode=TwoWay}" />
</controls:SettingsCard>
</StackPanel>
<!-- Separator line -->