Skip to content

Commit 71a46b1

Browse files
authored
Merge branch 'MaterialDesignInXAML:master' into master
2 parents 1f7dd72 + 0ff7d5d commit 71a46b1

15 files changed

+200
-114
lines changed

.github/workflows/get_versions.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ jobs:
2323
getting_versions:
2424
env:
2525
#Update these base version numbers
26-
mdix-version: "5.2.1"
27-
mdix-colors-version: "5.2.1"
28-
mdix-mahapps-version: "5.2.1"
26+
mdix-version: "5.2.2"
27+
mdix-colors-version: "5.2.2"
28+
mdix-mahapps-version: "5.2.2"
2929
name: Set version numbers
3030
runs-on: ubuntu-latest
3131
defaults:

.github/workflows/release.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,12 @@ on:
1010

1111
env:
1212
solution: MaterialDesignToolkit.Full.sln
13-
# Needed for GitHub CLI
14-
GITHUB_TOKEN: ${{ github.token }}
13+
GITHUB_TOKEN: ${{ secrets.SA_PAT }}
1514

1615
defaults:
1716
run:
1817
shell: pwsh
1918

20-
# Needed for updating the version numbers at the end of the pipeline
21-
permissions:
22-
id-token: write
23-
contents: write
2419

2520
jobs:
2621
get_versions:
@@ -277,9 +272,6 @@ jobs:
277272
name: Update Version Numbers
278273
environment: production
279274

280-
permissions:
281-
actions: write
282-
283275
steps:
284276
# Checkout is needed so that we can update the get_versions.yml file
285277
- uses: actions/checkout@v4
@@ -313,8 +305,6 @@ jobs:
313305
Update-Version -Prefix "mdix-mahapps-version"
314306
315307
- name: Open Pull Request
316-
env:
317-
GITHUB_TOKEN: ${{ secrets.SA_PAT }}
318308
run: |
319309
git config --local user.email "github-actions[bot]@users.noreply.github.com"
320310
git config --local user.name "github-actions[bot]"

src/MainDemo.Wpf/FieldsLineUp.xaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
<CheckBox x:Name="IsEnabledCheckBox"
109109
Content="IsEnabled"
110110
IsChecked="True" />
111+
<CheckBox x:Name="IsReadOnlyCheckBox" Content="TextBox.IsReadOnly" />
111112
<CheckBox x:Name="HasClearButtonCheckBox" Content="TextFieldAssist.HasClearButton" />
112113
<CheckBox x:Name="IsEditableCheckBox" Content="ComboBox.IsEditable" />
113114
</StackPanel>
@@ -159,6 +160,7 @@
159160
<ColumnDefinition MinWidth="100" />
160161
<ColumnDefinition MinWidth="100" />
161162
<ColumnDefinition MinWidth="100" />
163+
<ColumnDefinition MinWidth="100" />
162164
</Grid.ColumnDefinitions>
163165

164166
<TextBlock Grid.Row="1"
@@ -202,6 +204,10 @@
202204
Grid.Column="6"
203205
Style="{StaticResource FieldHeader}"
204206
Text="NumericUpDown" />
207+
<TextBlock Grid.Row="0"
208+
Grid.Column="7"
209+
Style="{StaticResource FieldHeader}"
210+
Text="AutoSuggestBox " />
205211

206212
<TextBox Grid.Row="1" Grid.Column="1" />
207213
<TextBox Grid.Row="2"
@@ -269,6 +275,17 @@
269275
Grid.Column="6"
270276
Style="{StaticResource MaterialDesignOutlinedNumericUpDown}" />
271277

278+
<materialDesign:AutoSuggestBox Grid.Row="1" Grid.Column="7" />
279+
<materialDesign:AutoSuggestBox Grid.Row="2"
280+
Grid.Column="7"
281+
Style="{StaticResource MaterialDesignFloatingHintAutoSuggestBox}" />
282+
<materialDesign:AutoSuggestBox Grid.Row="3"
283+
Grid.Column="7"
284+
Style="{StaticResource MaterialDesignFilledAutoSuggestBox}" />
285+
<materialDesign:AutoSuggestBox Grid.Row="4"
286+
Grid.Column="7"
287+
Style="{StaticResource MaterialDesignOutlinedAutoSuggestBox}" />
288+
272289
</Grid>
273290
</StackPanel>
274291
</GroupBox>

src/MainDemo.Wpf/FieldsLineUp.xaml.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public FieldsLineUp()
5252
control.Margin = new Thickness(2, 10, 2, 10);
5353
if (control is ComboBox comboBox)
5454
comboBox.SetBinding(ComboBox.IsEditableProperty, new Binding(nameof(CheckBox.IsChecked)) { ElementName = nameof(IsEditableCheckBox) });
55+
if (control is TextBoxBase tb)
56+
tb.SetBinding(TextBoxBase.IsReadOnlyProperty, new Binding(nameof(CheckBox.IsChecked)) { ElementName = nameof(IsReadOnlyCheckBox) });
5557
SetValue(control);
5658
}
5759
}
@@ -73,6 +75,9 @@ private static void SetValue(Control control)
7375
{
7476
switch (control)
7577
{
78+
case MaterialDesignThemes.Wpf.AutoSuggestBox autoSuggestBox:
79+
autoSuggestBox.Text = nameof(MaterialDesignThemes.Wpf.AutoSuggestBox.Text);
80+
break;
7681
case TextBox textBox:
7782
textBox.Text = nameof(TextBox.Text);
7883
break;

src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
<CheckBox x:Name="IsEnabledCheckBox"
9898
Content="IsEnabled"
9999
IsChecked="True" />
100+
<CheckBox x:Name="IsReadOnlyCheckBox" Content="TextBox.IsReadOnly" />
100101
<CheckBox x:Name="HasClearButtonCheckBox" Content="TextFieldAssist.HasClearButton" />
101102
<CheckBox x:Name="IsEditableCheckBox" Content="ComboBox.IsEditable" />
102103
</StackPanel>
@@ -148,6 +149,7 @@
148149
<ColumnDefinition MinWidth="100" />
149150
<ColumnDefinition MinWidth="100" />
150151
<ColumnDefinition MinWidth="100" />
152+
<ColumnDefinition MinWidth="100" />
151153
</Grid.ColumnDefinitions>
152154

153155
<TextBlock Grid.Row="1"
@@ -191,6 +193,10 @@
191193
Grid.Column="6"
192194
Style="{StaticResource FieldHeader}"
193195
Text="NumericUpDown" />
196+
<TextBlock Grid.Row="0"
197+
Grid.Column="7"
198+
Style="{StaticResource FieldHeader}"
199+
Text="AutoSuggestBox " />
194200

195201
<TextBox Grid.Row="1" Grid.Column="1" />
196202
<TextBox Grid.Row="2"
@@ -258,6 +264,17 @@
258264
Grid.Column="6"
259265
Style="{StaticResource MaterialDesignOutlinedNumericUpDown}" />
260266

267+
<materialDesign:AutoSuggestBox Grid.Row="1" Grid.Column="7" />
268+
<materialDesign:AutoSuggestBox Grid.Row="2"
269+
Grid.Column="7"
270+
Style="{StaticResource MaterialDesignFloatingHintAutoSuggestBox}" />
271+
<materialDesign:AutoSuggestBox Grid.Row="3"
272+
Grid.Column="7"
273+
Style="{StaticResource MaterialDesignFilledAutoSuggestBox}" />
274+
<materialDesign:AutoSuggestBox Grid.Row="4"
275+
Grid.Column="7"
276+
Style="{StaticResource MaterialDesignOutlinedAutoSuggestBox}" />
277+
261278
</Grid>
262279
</StackPanel>
263280
</GroupBox>

src/MaterialDesign3.Demo.Wpf/FieldsLineUp.xaml.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public FieldsLineUp()
5252
control.Margin = new Thickness(2, 10, 2, 10);
5353
if (control is ComboBox comboBox)
5454
comboBox.SetBinding(ComboBox.IsEditableProperty, new Binding(nameof(CheckBox.IsChecked)) { ElementName = nameof(IsEditableCheckBox) });
55+
if (control is TextBoxBase tb)
56+
tb.SetBinding(TextBoxBase.IsReadOnlyProperty, new Binding(nameof(CheckBox.IsChecked)) { ElementName = nameof(IsReadOnlyCheckBox) });
5557
SetValue(control);
5658
}
5759
}
@@ -73,6 +75,9 @@ private static void SetValue(Control control)
7375
{
7476
switch (control)
7577
{
78+
case MaterialDesignThemes.Wpf.AutoSuggestBox autoSuggestBox:
79+
autoSuggestBox.Text = nameof(MaterialDesignThemes.Wpf.AutoSuggestBox.Text);
80+
break;
7681
case TextBox textBox:
7782
textBox.Text = nameof(TextBox.Text);
7883
break;

src/MaterialDesignThemes.Wpf/Behaviors/TextBoxLineCountBehavior.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ public class TextBoxLineCountBehavior : Behavior<TextBox>
1212

1313
private void UpdateAttachedProperties()
1414
{
15-
AssociatedObject.SetCurrentValue(TextFieldAssist.TextBoxLineCountProperty, AssociatedObject.LineCount);
16-
AssociatedObject.SetCurrentValue(TextFieldAssist.TextBoxIsMultiLineProperty, AssociatedObject.LineCount > 1);
15+
if (AssociatedObject != null)
16+
{
17+
AssociatedObject.SetCurrentValue(TextFieldAssist.TextBoxLineCountProperty, AssociatedObject.LineCount);
18+
AssociatedObject.SetCurrentValue(TextFieldAssist.TextBoxIsMultiLineProperty, AssociatedObject.LineCount > 1);
19+
}
1720
}
1821

1922
protected override void OnAttached()

src/MaterialDesignThemes.Wpf/Converters/FloatingHintInitialHorizontalOffsetConverter.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public class FloatingHintInitialHorizontalOffsetConverter : IMultiValueConverter
1919
PrefixSuffixVisibility suffixVisibility,
2020
PrefixSuffixHintBehavior prefixHintBehavior,
2121
PrefixSuffixHintBehavior suffixHintBehavior,
22-
HorizontalAlignment horizontalContentAlignment
22+
HorizontalAlignment horizontalContentAlignment,
23+
bool isEditable,
2324
])
2425
{
2526
return 0;
@@ -37,8 +38,11 @@ double GetLeftOffset()
3738
return prefixVisibility switch
3839
{
3940
PrefixSuffixVisibility.WhenFocusedOrNonEmpty
40-
when prefixHintBehavior == PrefixSuffixHintBehavior.AlignWithText =>
41+
when prefixHintBehavior == PrefixSuffixHintBehavior.AlignWithText && isEditable =>
4142
prefixWidth + prefixMargin.Right,
43+
PrefixSuffixVisibility.WhenFocusedOrNonEmpty
44+
when prefixHintBehavior == PrefixSuffixHintBehavior.AlignWithPrefixSuffix && !isEditable && prefixWidth > 0 =>
45+
-(prefixWidth + prefixMargin.Right),
4246
PrefixSuffixVisibility.Always
4347
when prefixHintBehavior == PrefixSuffixHintBehavior.AlignWithPrefixSuffix =>
4448
-(prefixWidth + prefixMargin.Right),
@@ -51,8 +55,11 @@ double GetRightOffset()
5155
return suffixVisibility switch
5256
{
5357
PrefixSuffixVisibility.WhenFocusedOrNonEmpty
54-
when suffixHintBehavior == PrefixSuffixHintBehavior.AlignWithText =>
58+
when suffixHintBehavior == PrefixSuffixHintBehavior.AlignWithText && isEditable =>
5559
-(suffixWidth + suffixMargin.Left),
60+
PrefixSuffixVisibility.WhenFocusedOrNonEmpty
61+
when suffixHintBehavior == PrefixSuffixHintBehavior.AlignWithPrefixSuffix && !isEditable && suffixWidth > 0 =>
62+
suffixWidth + suffixMargin.Left,
5663
PrefixSuffixVisibility.Always
5764
when suffixHintBehavior == PrefixSuffixHintBehavior.AlignWithPrefixSuffix =>
5865
suffixWidth + suffixMargin.Left,

src/MaterialDesignThemes.Wpf/SmartHint.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ private void RefreshState(bool useTransitions)
258258
string state = string.Empty;
259259

260260
bool isEmpty = proxy.IsEmpty();
261-
bool isFocused = proxy.IsFocused();
261+
bool isFocused = HintHost?.IsKeyboardFocusWithin ?? proxy.IsFocused();
262262

263263
if (UseFloating)
264264
state = !isEmpty || isFocused ? HintFloatingPositionName : HintRestingPositionName;

src/MaterialDesignThemes.Wpf/TextFieldAssist.cs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static class TextFieldAssist
4141

4242
public static void SetTextBoxViewVerticalAlignment(DependencyObject element, VerticalAlignment value) => element.SetValue(TextBoxViewVerticalAlignmentProperty, value);
4343

44-
public static VerticalAlignment GetTextBoxViewVerticalAlignment(DependencyObject element) => (VerticalAlignment) element.GetValue(TextBoxViewVerticalAlignmentProperty);
44+
public static VerticalAlignment GetTextBoxViewVerticalAlignment(DependencyObject element) => (VerticalAlignment)element.GetValue(TextBoxViewVerticalAlignmentProperty);
4545

4646
/// <summary>
4747
/// Controls the visibility of the underline decoration.
@@ -172,7 +172,7 @@ public static void SetSuffixTextVisibility(DependencyObject element, PrefixSuffi
172172
=> element.SetValue(SuffixTextVisibilityProperty, value);
173173

174174
public static PrefixSuffixVisibility GetSuffixTextVisibility(DependencyObject element)
175-
=> (PrefixSuffixVisibility) element.GetValue(SuffixTextVisibilityProperty);
175+
=> (PrefixSuffixVisibility)element.GetValue(SuffixTextVisibilityProperty);
176176

177177
/// <summary>
178178
/// SuffixTextHintBehavior dependency property. Controls how a floating hint aligns with respect to the text and suffix.
@@ -184,7 +184,7 @@ public static void SetSuffixTextHintBehavior(DependencyObject element, PrefixSuf
184184
=> element.SetValue(SuffixTextHintBehaviorProperty, value);
185185

186186
public static PrefixSuffixHintBehavior GetSuffixTextHintBehavior(DependencyObject element)
187-
=> (PrefixSuffixHintBehavior) element.GetValue(SuffixTextHintBehaviorProperty);
187+
=> (PrefixSuffixHintBehavior)element.GetValue(SuffixTextHintBehaviorProperty);
188188

189189
/// <summary>
190190
/// PrefixText dependency property
@@ -208,7 +208,7 @@ public static void SetPrefixTextVisibility(DependencyObject element, PrefixSuffi
208208
=> element.SetValue(PrefixTextVisibilityProperty, value);
209209

210210
public static PrefixSuffixVisibility GetPrefixTextVisibility(DependencyObject element)
211-
=> (PrefixSuffixVisibility) element.GetValue(PrefixTextVisibilityProperty);
211+
=> (PrefixSuffixVisibility)element.GetValue(PrefixTextVisibilityProperty);
212212

213213
/// <summary>
214214
/// PrefixTextHintBehavior dependency property. Controls how a floating hint aligns with respect to the text and prefix.
@@ -234,6 +234,18 @@ public static void SetHasClearButton(DependencyObject element, bool value)
234234
public static bool GetHasClearButton(DependencyObject element)
235235
=> (bool)element.GetValue(HasClearButtonProperty);
236236

237+
/// <summary>
238+
/// Controls the size of the clear button.
239+
/// </summary>
240+
public static readonly DependencyProperty ClearButtonSizeProperty = DependencyProperty.RegisterAttached(
241+
"ClearButtonSize", typeof(double), typeof(TextFieldAssist), new PropertyMetadata(16.0d));
242+
243+
public static void SetClearButtonSize(DependencyObject element, double value)
244+
=> element.SetValue(ClearButtonSizeProperty, value);
245+
246+
public static double GetClearButtonSize(DependencyObject element)
247+
=> (double)element.GetValue(ClearButtonSizeProperty);
248+
237249
/// <summary>
238250
/// Controls visibility of the leading icon
239251
/// </summary>
@@ -316,7 +328,7 @@ public static void SetIconVerticalAlignment(DependencyObject element, VerticalAl
316328
=> element.SetValue(IconVerticalAlignmentProperty, value);
317329

318330
public static VerticalAlignment GetIconVerticalAlignment(DependencyObject element)
319-
=> (VerticalAlignment) element.GetValue(IconVerticalAlignmentProperty);
331+
=> (VerticalAlignment)element.GetValue(IconVerticalAlignmentProperty);
320332

321333
public static Style GetCharacterCounterStyle(DependencyObject obj) => (Style)obj.GetValue(CharacterCounterStyleProperty);
322334

@@ -373,14 +385,14 @@ public static Thickness GetOutlinedBorderActiveThickness(DependencyObject elemen
373385
public static void SetTextBoxLineCount(DependencyObject element, int value)
374386
=> element.SetValue(TextBoxLineCountProperty, value);
375387
public static int GetTextBoxLineCount(DependencyObject element)
376-
=> (int) element.GetValue(TextBoxLineCountProperty);
388+
=> (int)element.GetValue(TextBoxLineCountProperty);
377389

378390
public static readonly DependencyProperty TextBoxIsMultiLineProperty = DependencyProperty.RegisterAttached(
379391
"TextBoxIsMultiLine", typeof(bool), typeof(TextFieldAssist), new PropertyMetadata(false));
380392
public static void SetTextBoxIsMultiLine(DependencyObject element, bool value)
381393
=> element.SetValue(TextBoxIsMultiLineProperty, value);
382394
public static bool GetTextBoxIsMultiLine(DependencyObject element)
383-
=> (bool) element.GetValue(TextBoxIsMultiLineProperty);
395+
=> (bool)element.GetValue(TextBoxIsMultiLineProperty);
384396

385397
#region Methods
386398

0 commit comments

Comments
 (0)