This commit is contained in:
PrefacedCorg
2026-04-17 01:20:06 +08:00
parent 8a8cf9a679
commit edc94547ab
10 changed files with 73 additions and 68 deletions
@@ -113,6 +113,34 @@ namespace Ink_Canvas.Controls
set => LabelTextBlock.Foreground = value;
}
public static readonly DependencyProperty IsEnabledBindingProperty = DependencyProperty.Register(
nameof(IsEnabledBinding), typeof(bool?), typeof(BoardToolbarButton),
new PropertyMetadata(null, OnIsEnabledBindingChanged));
private static void OnIsEnabledBindingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var button = (BoardToolbarButton)d;
if (e.NewValue is bool isEnabled)
{
button.IsEnabled = isEnabled;
button.UpdateIconOpacity(isEnabled);
}
}
public bool? IsEnabledBinding
{
get => (bool?)GetValue(IsEnabledBindingProperty);
set => SetValue(IsEnabledBindingProperty, value);
}
private void UpdateIconOpacity(bool isEnabled)
{
if (ButtonImage != null)
{
ButtonImage.Opacity = isEnabled ? 1.0 : 0.4;
}
}
public BoardToolbarButton()
{
InitializeComponent();