FlatCheckBox.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Media;
  8. namespace CustomUI
  9. {
  10. public enum CheckBoxSkinsEnum
  11. {
  12. /// <summary>
  13. /// 方形的CheckBox
  14. /// </summary>
  15. DefaultSquare,
  16. /// <summary>
  17. /// 圆形的CheckBox
  18. /// </summary>
  19. DefaultEllipse,
  20. EllipseSkin1,
  21. }
  22. public class FlatCheckBox : CheckBox
  23. {
  24. static FlatCheckBox()
  25. {
  26. DefaultStyleKeyProperty.OverrideMetadata(typeof(FlatCheckBox), new FrameworkPropertyMetadata(typeof(FlatCheckBox)));
  27. }
  28. #region 依赖属性
  29. public static readonly DependencyProperty SkinsProperty = DependencyProperty.Register("Skins"
  30. , typeof(CheckBoxSkinsEnum), typeof(FlatCheckBox), new PropertyMetadata(CheckBoxSkinsEnum.DefaultSquare));
  31. /// <summary>
  32. /// CheckBox皮肤样式
  33. /// </summary>
  34. public CheckBoxSkinsEnum Skins
  35. {
  36. get { return (CheckBoxSkinsEnum)GetValue(SkinsProperty); }
  37. set { SetValue(SkinsProperty, value); }
  38. }
  39. public static readonly DependencyProperty UnCheckedColorProperty = DependencyProperty.Register("UnCheckedColor"
  40. , typeof(Brush), typeof(FlatCheckBox));
  41. /// <summary>
  42. /// CheckBox未选中时的颜色
  43. /// </summary>
  44. public Brush UnCheckedColor
  45. {
  46. get { return (Brush)GetValue(UnCheckedColorProperty); }
  47. set { SetValue(UnCheckedColorProperty, value); }
  48. }
  49. public static readonly DependencyProperty CheckedColorProperty = DependencyProperty.Register("CheckedColor"
  50. , typeof(Brush), typeof(FlatCheckBox));
  51. /// <summary>
  52. /// CheckBox选中后的颜色
  53. /// </summary>
  54. public Brush CheckedColor
  55. {
  56. get { return (Brush)GetValue(CheckedColorProperty); }
  57. set { SetValue(CheckedColorProperty, value); }
  58. }
  59. #endregion
  60. }
  61. }