Skip to content

Commit

Permalink
[SmartHint] Fix minor UI jump (#3768)
Browse files Browse the repository at this point in the history
* Add TextBox.IsReadOnly option to "fields line up" demo pages

* Add extra condition in converter to avoid minor UI jump
  • Loading branch information
nicolaihenriksen authored Jan 13, 2025
1 parent 17d5e27 commit 32e2584
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/MainDemo.Wpf/FieldsLineUp.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<CheckBox x:Name="IsEnabledCheckBox"
Content="IsEnabled"
IsChecked="True" />
<CheckBox x:Name="IsReadOnlyCheckBox" Content="TextBox.IsReadOnly" />
<CheckBox x:Name="HasClearButtonCheckBox" Content="TextFieldAssist.HasClearButton" />
<CheckBox x:Name="IsEditableCheckBox" Content="ComboBox.IsEditable" />
</StackPanel>
Expand Down
2 changes: 2 additions & 0 deletions src/MainDemo.Wpf/FieldsLineUp.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public FieldsLineUp()
control.Margin = new Thickness(2, 10, 2, 10);
if (control is ComboBox comboBox)
comboBox.SetBinding(ComboBox.IsEditableProperty, new Binding(nameof(CheckBox.IsChecked)) { ElementName = nameof(IsEditableCheckBox) });
if (control is TextBoxBase tb)
tb.SetBinding(TextBoxBase.IsReadOnlyProperty, new Binding(nameof(CheckBox.IsChecked)) { ElementName = nameof(IsReadOnlyCheckBox) });
SetValue(control);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
<CheckBox x:Name="IsEnabledCheckBox"
Content="IsEnabled"
IsChecked="True" />
<CheckBox x:Name="IsReadOnlyCheckBox" Content="TextBox.IsReadOnly" />
<CheckBox x:Name="HasClearButtonCheckBox" Content="TextFieldAssist.HasClearButton" />
<CheckBox x:Name="IsEditableCheckBox" Content="ComboBox.IsEditable" />
</StackPanel>
Expand Down
2 changes: 2 additions & 0 deletions src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public FieldsLineUp()
control.Margin = new Thickness(2, 10, 2, 10);
if (control is ComboBox comboBox)
comboBox.SetBinding(ComboBox.IsEditableProperty, new Binding(nameof(CheckBox.IsChecked)) { ElementName = nameof(IsEditableCheckBox) });
if (control is TextBoxBase tb)
tb.SetBinding(TextBoxBase.IsReadOnlyProperty, new Binding(nameof(CheckBox.IsChecked)) { ElementName = nameof(IsReadOnlyCheckBox) });
SetValue(control);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ double GetLeftOffset()
when prefixHintBehavior == PrefixSuffixHintBehavior.AlignWithText && isEditable =>
prefixWidth + prefixMargin.Right,
PrefixSuffixVisibility.WhenFocusedOrNonEmpty
when prefixHintBehavior == PrefixSuffixHintBehavior.AlignWithPrefixSuffix && !isEditable =>
when prefixHintBehavior == PrefixSuffixHintBehavior.AlignWithPrefixSuffix && !isEditable && prefixWidth > 0 =>
-(prefixWidth + prefixMargin.Right),
PrefixSuffixVisibility.Always
when prefixHintBehavior == PrefixSuffixHintBehavior.AlignWithPrefixSuffix =>
Expand All @@ -58,7 +58,7 @@ double GetRightOffset()
when suffixHintBehavior == PrefixSuffixHintBehavior.AlignWithText && isEditable =>
-(suffixWidth + suffixMargin.Left),
PrefixSuffixVisibility.WhenFocusedOrNonEmpty
when suffixHintBehavior == PrefixSuffixHintBehavior.AlignWithPrefixSuffix && !isEditable =>
when suffixHintBehavior == PrefixSuffixHintBehavior.AlignWithPrefixSuffix && !isEditable && suffixWidth > 0 =>
suffixWidth + suffixMargin.Left,
PrefixSuffixVisibility.Always
when suffixHintBehavior == PrefixSuffixHintBehavior.AlignWithPrefixSuffix =>
Expand Down

0 comments on commit 32e2584

Please sign in to comment.