Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/Wpf.Ui/Controls/TextBox/TextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ public class TextBox : System.Windows.Controls.TextBox
nameof(PlaceholderEnabled),
typeof(bool),
typeof(TextBox),
new PropertyMetadata(true)
new PropertyMetadata(true, OnPlaceholderEnabledChanged)
);

/// <summary>Identifies the <see cref="CurrentPlaceholderEnabled"/> dependency property.</summary>
public static readonly DependencyProperty CurrentPlaceholderEnabledProperty = DependencyProperty.Register(
nameof(CurrentPlaceholderEnabled),
typeof(bool),
typeof(TextBox),
new PropertyMetadata(true));
new PropertyMetadata(true)
);

/// <summary>Identifies the <see cref="ClearButtonEnabled"/> dependency property.</summary>
public static readonly DependencyProperty ClearButtonEnabledProperty = DependencyProperty.Register(
Expand Down Expand Up @@ -197,7 +198,7 @@ protected void SetPlaceholderTextVisibility()
SetCurrentValue(CurrentPlaceholderEnabledProperty, true);
}
}
else
else if (CurrentPlaceholderEnabled)
{
SetCurrentValue(CurrentPlaceholderEnabledProperty, false);
}
Expand Down Expand Up @@ -263,4 +264,19 @@ protected virtual void OnTemplateButtonClick(string? parameter)

OnClearButtonClick();
}

private static void OnPlaceholderEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is not TextBox control)
{
return;
}

control.OnPlaceholderEnabledChanged();
}

protected virtual void OnPlaceholderEnabledChanged()
{
SetPlaceholderTextVisibility();
}
}