Skip to content

Commit

Permalink
Application of BindingProxy to ensure binding to HardwareNameLengthRule
Browse files Browse the repository at this point in the history
  • Loading branch information
TTLC198 committed Sep 9, 2023
1 parent 6f97ab6 commit b871ba9
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions HSMonitor/Views/Settings/AppearanceSettingsTabView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
xmlns:converters="clr-namespace:HSMonitor.Utils.Converters"
xmlns:validationRules="clr-namespace:HSMonitor.Utils.ValidationRules"
xmlns:p="clr-namespace:HSMonitor.Properties"
xmlns:utils="clr-namespace:HSMonitor.Utils"
d:DataContext="{d:DesignInstance Type=settings:AppearanceSettingsTabViewModel}"
Style="{DynamicResource MaterialDesignRoot}"
mc:Ignorable="d"
Background="Transparent">
<UserControl.Resources>
<utils:BindingProxy x:Key="MaxProxy" Data="{Binding CustomNameMaxLength, Mode=OneWay}"/>
<Style
TargetType="{x:Type Grid}">
<Setter
Expand Down Expand Up @@ -61,10 +63,12 @@
UpdateSourceTrigger="PropertyChanged"
Mode="TwoWay">
<Binding.ValidationRules>
<validationRules:HardwareNameLengthRule
Max="{Binding CustomNameMaxLength}"
Min="5"
ValidatesOnTargetUpdated="True"/>
<validationRules:HardwareNameLengthRule
ValidatesOnTargetUpdated="True">
<validationRules:HardwareNameLengthRuleValue
Min="5"
Max="{Binding Data, Source={StaticResource MaxProxy}}"/>
</validationRules:HardwareNameLengthRule>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
Expand All @@ -90,10 +94,12 @@
UpdateSourceTrigger="PropertyChanged"
Mode="TwoWay">
<Binding.ValidationRules>
<validationRules:HardwareNameLengthRule
Max="{Binding CustomNameMaxLength}"
Min="5"
ValidatesOnTargetUpdated="True"/>
<validationRules:HardwareNameLengthRule
ValidatesOnTargetUpdated="True">
<validationRules:HardwareNameLengthRuleValue
Min="5"
Max="{Binding Data, Source={StaticResource MaxProxy}}"/>
</validationRules:HardwareNameLengthRule>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
Expand Down

0 comments on commit b871ba9

Please sign in to comment.