ZCheckBox.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. using System.Windows.Media;
  4. namespace CustomUI
  5. {
  6. public class ZCheckBox : CheckBox
  7. {
  8. static ZCheckBox()
  9. {
  10. DefaultStyleKeyProperty.OverrideMetadata(typeof(ZCheckBox), new FrameworkPropertyMetadata(typeof(ZCheckBox)));
  11. }
  12. #region 依赖属性
  13. #region UnCheckedColor
  14. public static readonly DependencyProperty UnCheckedColorProperty = DependencyProperty.Register("UnCheckedColor"
  15. , typeof(Brush), typeof(ZCheckBox));
  16. /// <summary>
  17. /// CheckBox未选中时的颜色
  18. /// </summary>
  19. public Brush UnCheckedColor
  20. {
  21. get { return (Brush)GetValue(UnCheckedColorProperty); }
  22. set { SetValue(UnCheckedColorProperty, value); }
  23. }
  24. #endregion
  25. #region CheckedColor
  26. public static readonly DependencyProperty CheckedColorProperty = DependencyProperty.Register("CheckedColor"
  27. , typeof(Brush), typeof(ZCheckBox));
  28. /// <summary>
  29. /// CheckBox选中后的颜色
  30. /// </summary>
  31. public Brush CheckedColor
  32. {
  33. get { return (Brush)GetValue(CheckedColorProperty); }
  34. set { SetValue(CheckedColorProperty, value); }
  35. }
  36. #endregion
  37. #region CornerRadius
  38. public CornerRadius CornerRadius
  39. {
  40. get { return (CornerRadius)GetValue(CornerRadiusProperty); }
  41. set { SetValue(CornerRadiusProperty, value); }
  42. }
  43. public static readonly DependencyProperty CornerRadiusProperty =
  44. DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(ZCheckBox));
  45. #endregion
  46. #endregion
  47. }
  48. }