Skip to content

Commit

Permalink
Use native UpdateSourceTrigger=LostFocus instead of the behavior wo…
Browse files Browse the repository at this point in the history
…rkaround
  • Loading branch information
Tyrrrz committed Aug 23, 2024
1 parent d64896c commit 9b5ec39
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 108 deletions.
65 changes: 0 additions & 65 deletions LightBulb/Behaviors/LostFocusUpdateBindingBehavior.cs

This file was deleted.

1 change: 0 additions & 1 deletion LightBulb/LightBulb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<PackageReference Include="Avalonia" Version="11.1.1" />
<PackageReference Include="Avalonia.Desktop" Version="11.1.1" />
<PackageReference Include="Avalonia.Diagnostics" Version="11.1.1" Condition="'$(Configuration)' == 'Debug'" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.1.0" />
<PackageReference Include="Cogwheel" Version="2.1.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="CSharpier.MsBuild" Version="0.28.2" PrivateAssets="all" />
Expand Down
43 changes: 12 additions & 31 deletions LightBulb/Views/Components/Settings/GeneralSettingsTabView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
x:Class="LightBulb.Views.Components.Settings.GeneralSettingsTabView"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:behaviors="clr-namespace:LightBulb.Behaviors"
xmlns:converters="clr-namespace:LightBulb.Converters"
xmlns:settings="clr-namespace:LightBulb.ViewModels.Components.Settings"
x:DataType="settings:GeneralSettingsTabViewModel">
Expand All @@ -14,11 +13,8 @@
MinWidth="24"
HorizontalAlignment="Right"
DockPanel.Dock="Right"
Theme="{DynamicResource CompactTextBox}">
<Interaction.Behaviors>
<behaviors:LostFocusUpdateBindingBehavior Text="{Binding DayTemperature, Converter={x:Static converters:DoubleToStringConverter.Instance}}" />
</Interaction.Behaviors>
</TextBox>
Text="{Binding DayTemperature, Converter={x:Static converters:DoubleToStringConverter.Instance}, UpdateSourceTrigger=LostFocus}"
Theme="{DynamicResource CompactTextBox}" />
</DockPanel>
<Slider
Margin="0,12,0,0"
Expand All @@ -37,11 +33,8 @@
MinWidth="24"
HorizontalAlignment="Right"
DockPanel.Dock="Right"
Theme="{DynamicResource CompactTextBox}">
<Interaction.Behaviors>
<behaviors:LostFocusUpdateBindingBehavior Text="{Binding NightTemperature, Converter={x:Static converters:DoubleToStringConverter.Instance}}" />
</Interaction.Behaviors>
</TextBox>
Text="{Binding NightTemperature, Converter={x:Static converters:DoubleToStringConverter.Instance}, UpdateSourceTrigger=LostFocus}"
Theme="{DynamicResource CompactTextBox}" />
</DockPanel>
<Slider
Margin="0,12,0,0"
Expand Down Expand Up @@ -73,11 +66,8 @@
MinWidth="24"
HorizontalAlignment="Right"
DockPanel.Dock="Right"
Theme="{DynamicResource CompactTextBox}">
<Interaction.Behaviors>
<behaviors:LostFocusUpdateBindingBehavior Text="{Binding DayBrightness, Converter={x:Static converters:FractionToPercentageStringConverter.Instance}}" />
</Interaction.Behaviors>
</TextBox>
Text="{Binding DayBrightness, Converter={x:Static converters:FractionToPercentageStringConverter.Instance}, UpdateSourceTrigger=LostFocus}"
Theme="{DynamicResource CompactTextBox}" />
</DockPanel>
<Slider
Margin="0,12,0,0"
Expand Down Expand Up @@ -109,11 +99,8 @@
MinWidth="24"
HorizontalAlignment="Right"
DockPanel.Dock="Right"
Theme="{DynamicResource CompactTextBox}">
<Interaction.Behaviors>
<behaviors:LostFocusUpdateBindingBehavior Text="{Binding NightBrightness, Converter={x:Static converters:FractionToPercentageStringConverter.Instance}}" />
</Interaction.Behaviors>
</TextBox>
Text="{Binding NightBrightness, Converter={x:Static converters:FractionToPercentageStringConverter.Instance}, UpdateSourceTrigger=LostFocus}"
Theme="{DynamicResource CompactTextBox}" />
</DockPanel>
<Slider
Margin="0,12,0,0"
Expand All @@ -132,11 +119,8 @@
MinWidth="48"
HorizontalAlignment="Right"
DockPanel.Dock="Right"
Theme="{DynamicResource CompactTextBox}">
<Interaction.Behaviors>
<behaviors:LostFocusUpdateBindingBehavior Text="{Binding ConfigurationTransitionDuration, Converter={x:Static converters:TimeSpanToDurationStringConverter.Instance}}" />
</Interaction.Behaviors>
</TextBox>
Text="{Binding ConfigurationTransitionDuration, Converter={x:Static converters:TimeSpanToDurationStringConverter.Instance}, UpdateSourceTrigger=LostFocus}"
Theme="{DynamicResource CompactTextBox}" />
</DockPanel>
<Slider
Margin="0,12,0,0"
Expand All @@ -153,11 +137,8 @@
MinWidth="24"
HorizontalAlignment="Right"
DockPanel.Dock="Right"
Theme="{DynamicResource CompactTextBox}">
<Interaction.Behaviors>
<behaviors:LostFocusUpdateBindingBehavior Text="{Binding ConfigurationTransitionOffset, Converter={x:Static converters:FractionToPercentageStringConverter.Instance}}" />
</Interaction.Behaviors>
</TextBox>
Text="{Binding ConfigurationTransitionOffset, Converter={x:Static converters:FractionToPercentageStringConverter.Instance}, UpdateSourceTrigger=LostFocus}"
Theme="{DynamicResource CompactTextBox}" />
</DockPanel>
<Slider
Margin="0,12,0,0"
Expand Down
15 changes: 4 additions & 11 deletions LightBulb/Views/Components/Settings/LocationSettingsTabView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
x:Class="LightBulb.Views.Components.Settings.LocationSettingsTabView"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:behaviors="clr-namespace:LightBulb.Behaviors"
xmlns:converters="clr-namespace:LightBulb.Converters"
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
xmlns:settings="clr-namespace:LightBulb.ViewModels.Components.Settings"
Expand Down Expand Up @@ -36,11 +35,8 @@
MinWidth="24"
HorizontalAlignment="Right"
DockPanel.Dock="Right"
Theme="{DynamicResource CompactTextBox}">
<Interaction.Behaviors>
<behaviors:LostFocusUpdateBindingBehavior Text="{Binding ManualSunrise, Converter={x:Static converters:TimeOnlyToStringConverter.Instance}}" />
</Interaction.Behaviors>
</TextBox>
Text="{Binding ManualSunrise, Converter={x:Static converters:TimeOnlyToStringConverter.Instance}, UpdateSourceTrigger=LostFocus}"
Theme="{DynamicResource CompactTextBox}" />
</DockPanel>
<Slider
Margin="0,12,0,0"
Expand All @@ -57,11 +53,8 @@
MinWidth="24"
HorizontalAlignment="Right"
DockPanel.Dock="Right"
Theme="{DynamicResource CompactTextBox}">
<Interaction.Behaviors>
<behaviors:LostFocusUpdateBindingBehavior Text="{Binding ManualSunset, Converter={x:Static converters:TimeOnlyToStringConverter.Instance}}" />
</Interaction.Behaviors>
</TextBox>
Text="{Binding ManualSunset, Converter={x:Static converters:TimeOnlyToStringConverter.Instance}, UpdateSourceTrigger=LostFocus}"
Theme="{DynamicResource CompactTextBox}" />
</DockPanel>
<Slider
Margin="0,12,0,0"
Expand Down

0 comments on commit 9b5ec39

Please sign in to comment.