更新
This commit is contained in:
53
WPFDark/Controls/BiaIconToggleButton.xaml.cs
Normal file
53
WPFDark/Controls/BiaIconToggleButton.xaml.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace WPFDark.Controls
|
||||
{
|
||||
public class BiaIconToggleButton : BiaIconButton
|
||||
{
|
||||
#region IsChecked
|
||||
|
||||
public bool IsChecked
|
||||
{
|
||||
get => _IsChecked;
|
||||
set
|
||||
{
|
||||
if (value != _IsChecked)
|
||||
SetValue(IsCheckedProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _IsChecked;
|
||||
|
||||
public static readonly DependencyProperty IsCheckedProperty =
|
||||
DependencyProperty.Register(nameof(IsChecked), typeof(bool), typeof(BiaIconToggleButton),
|
||||
new FrameworkPropertyMetadata(
|
||||
false,
|
||||
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault |
|
||||
FrameworkPropertyMetadataOptions.AffectsRender |
|
||||
FrameworkPropertyMetadataOptions.SubPropertiesDoNotAffectRender,
|
||||
(s, e) =>
|
||||
{
|
||||
var self = (BiaIconToggleButton) s;
|
||||
self._IsChecked = (bool) e.NewValue;
|
||||
})
|
||||
{
|
||||
BindsTwoWayByDefault = true
|
||||
}
|
||||
);
|
||||
|
||||
#endregion
|
||||
|
||||
static BiaIconToggleButton()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(BiaIconToggleButton),
|
||||
new FrameworkPropertyMetadata(typeof(BiaIconToggleButton)));
|
||||
}
|
||||
|
||||
protected override void Clicked()
|
||||
{
|
||||
IsChecked = !IsChecked;
|
||||
|
||||
base.Clicked();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user