ZGroupBox.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 class ZGroupBox : HeaderedContentControl
  11. {
  12. #region Private属性
  13. #endregion
  14. #region 依赖属性定义
  15. #region HeaderBackground
  16. public Brush HeaderBackground
  17. {
  18. get { return (Brush)GetValue(HeaderBackgroundProperty); }
  19. set { SetValue(HeaderBackgroundProperty, value); }
  20. }
  21. public static readonly DependencyProperty HeaderBackgroundProperty =
  22. DependencyProperty.Register("HeaderBackground", typeof(Brush), typeof(ZGroupBox));
  23. #endregion
  24. #region HorizontalHeaderAlignment
  25. public HorizontalAlignment HorizontalHeaderAlignment
  26. {
  27. get { return (HorizontalAlignment)GetValue(HorizontalHeaderAlignmentProperty); }
  28. set { SetValue(HorizontalHeaderAlignmentProperty, value); }
  29. }
  30. public static readonly DependencyProperty HorizontalHeaderAlignmentProperty =
  31. DependencyProperty.Register("HorizontalHeaderAlignment", typeof(HorizontalAlignment), typeof(ZGroupBox), new PropertyMetadata(HorizontalAlignment.Stretch));
  32. #endregion
  33. #region HeaderPadding
  34. public Thickness HeaderPadding
  35. {
  36. get { return (Thickness)GetValue(HeaderPaddingProperty); }
  37. set { SetValue(HeaderPaddingProperty, value); }
  38. }
  39. public static readonly DependencyProperty HeaderPaddingProperty =
  40. DependencyProperty.Register("HeaderPadding", typeof(Thickness), typeof(ZGroupBox));
  41. #endregion
  42. #region CornerRadius
  43. public CornerRadius CornerRadius
  44. {
  45. get { return (CornerRadius)GetValue(CornerRadiusProperty); }
  46. set { SetValue(CornerRadiusProperty, value); }
  47. }
  48. public static readonly DependencyProperty CornerRadiusProperty =
  49. DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(ZGroupBox), new PropertyMetadata(new CornerRadius(0), CornerRadiusCallback));
  50. private static void CornerRadiusCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  51. {
  52. ZGroupBox groupBox = d as ZGroupBox;
  53. if(groupBox != null)
  54. {
  55. CornerRadius radius = (CornerRadius)e.NewValue;
  56. groupBox.CornerRadiusInner = new CornerRadius(radius.TopLeft, radius.TopRight, 0, 0);
  57. }
  58. }
  59. #endregion
  60. #endregion
  61. #region 私有依赖属性
  62. #region CornerRadiusInner
  63. public CornerRadius CornerRadiusInner
  64. {
  65. get { return (CornerRadius)GetValue(CornerRadiusInnerProperty); }
  66. private set { SetValue(CornerRadiusInnerProperty, value); }
  67. }
  68. public static readonly DependencyProperty CornerRadiusInnerProperty =
  69. DependencyProperty.Register("CornerRadiusInner", typeof(CornerRadius), typeof(ZGroupBox));
  70. #endregion
  71. #endregion
  72. #region Constructors
  73. static ZGroupBox()
  74. {
  75. DefaultStyleKeyProperty.OverrideMetadata(typeof(ZGroupBox), new FrameworkPropertyMetadata(typeof(ZGroupBox)));
  76. }
  77. #endregion
  78. #region Override方法
  79. #endregion
  80. #region Private方法
  81. #endregion
  82. }
  83. }