init branch

This commit is contained in:
NaBian committed 2019-08-28 21:57:54 +08:00
1 parent 9a5c6771a3
commit fb6ee4e702
19 files changed
+74 -4

No files matched your search

@@ -0,0 +1,62 @@
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using HandyControl.Data;
namespace HandyControl.Controls
{
/// <summary>
/// 切换块
/// </summary>
/// <remarks>
/// 在不需要命中测试的情况下可代替ToggleButton或CheckBox,以减少内存用量。
/// </remarks>
public class ToggleBlock : Control
{
public static readonly DependencyProperty IsCheckedProperty = DependencyProperty.Register(
"IsChecked", typeof(bool?), typeof(ToggleBlock), new FrameworkPropertyMetadata(ValueBoxes.FalseBox,
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal));
[Category("Appearance")]
[TypeConverter(typeof(NullableBoolConverter))]
[Localizability(LocalizationCategory.None, Readability = Readability.Unreadable)]
public bool? IsChecked
{
get
{
// Because Nullable<bool> unboxing is very slow (uses reflection) first we cast to bool
var value = GetValue(IsCheckedProperty);
// ReSharper disable once RedundantExplicitNullableCreation
return value == null ? new bool?() : new bool?((bool)value);
}
set => SetValue(IsCheckedProperty, value.HasValue ? ValueBoxes.BooleanBox(value.Value) : null);
}
public static readonly DependencyProperty CheckedContentProperty = DependencyProperty.Register(
"CheckedContent", typeof(object), typeof(ToggleBlock), new PropertyMetadata(default(object)));
public object CheckedContent
{
get => GetValue(CheckedContentProperty);
set => SetValue(CheckedContentProperty, value);
}
public static readonly DependencyProperty UnCheckedContentProperty = DependencyProperty.Register(
"UnCheckedContent", typeof(object), typeof(ToggleBlock), new PropertyMetadata(default(object)));
public object UnCheckedContent
{
get => GetValue(UnCheckedContentProperty);
set => SetValue(UnCheckedContentProperty, value);
}
public static readonly DependencyProperty IndeterminateContentProperty = DependencyProperty.Register(
"IndeterminateContent", typeof(object), typeof(ToggleBlock), new PropertyMetadata(default(object)));
public object IndeterminateContent
{
get => GetValue(IndeterminateContentProperty);
set => SetValue(IndeterminateContentProperty, value);
}
}
}