Skip to content

Commit

Permalink
Merge branch 'development' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
m0lDaViA authored Jun 10, 2024
2 parents f391c61 + ba8a241 commit ff35a07
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/documentation/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Wpf.Ui.Appearance.ApplicationThemeManager.Apply(

### Automatic change

The theme can be changed automatically when the operating system changes its background or accent using the [Watcher](https://github.com/lepoco/wpfui/blob/main/src/Wpf.Ui/Appearance/Watcher.cs) class.
The theme can be changed automatically when the operating system changes its background or accent using the [SystemThemeWatcher](https://github.com/lepoco/wpfui/blob/main/src/Wpf.Ui/Appearance/SystemThemeWatcher.cs) class.

```csharp
namespace MyApp;
Expand Down
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();
}
}

0 comments on commit ff35a07

Please sign in to comment.