| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Media;
- namespace CustomUI
- {
- public class ZGroupBox : HeaderedContentControl
- {
- #region Private属性
- #endregion
- #region 依赖属性定义
- #region HeaderBackground
- public Brush HeaderBackground
- {
- get { return (Brush)GetValue(HeaderBackgroundProperty); }
- set { SetValue(HeaderBackgroundProperty, value); }
- }
- public static readonly DependencyProperty HeaderBackgroundProperty =
- DependencyProperty.Register("HeaderBackground", typeof(Brush), typeof(ZGroupBox));
- #endregion
- #region HorizontalHeaderAlignment
- public HorizontalAlignment HorizontalHeaderAlignment
- {
- get { return (HorizontalAlignment)GetValue(HorizontalHeaderAlignmentProperty); }
- set { SetValue(HorizontalHeaderAlignmentProperty, value); }
- }
-
- public static readonly DependencyProperty HorizontalHeaderAlignmentProperty =
- DependencyProperty.Register("HorizontalHeaderAlignment", typeof(HorizontalAlignment), typeof(ZGroupBox), new PropertyMetadata(HorizontalAlignment.Stretch));
- #endregion
- #region HeaderPadding
- public Thickness HeaderPadding
- {
- get { return (Thickness)GetValue(HeaderPaddingProperty); }
- set { SetValue(HeaderPaddingProperty, value); }
- }
-
- public static readonly DependencyProperty HeaderPaddingProperty =
- DependencyProperty.Register("HeaderPadding", typeof(Thickness), typeof(ZGroupBox));
- #endregion
- #region CornerRadius
- public CornerRadius CornerRadius
- {
- get { return (CornerRadius)GetValue(CornerRadiusProperty); }
- set { SetValue(CornerRadiusProperty, value); }
- }
- public static readonly DependencyProperty CornerRadiusProperty =
- DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(ZGroupBox), new PropertyMetadata(new CornerRadius(0), CornerRadiusCallback));
- private static void CornerRadiusCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- ZGroupBox groupBox = d as ZGroupBox;
- if(groupBox != null)
- {
- CornerRadius radius = (CornerRadius)e.NewValue;
- groupBox.CornerRadiusInner = new CornerRadius(radius.TopLeft, radius.TopRight, 0, 0);
- }
- }
- #endregion
- #endregion
- #region 私有依赖属性
- #region CornerRadiusInner
- public CornerRadius CornerRadiusInner
- {
- get { return (CornerRadius)GetValue(CornerRadiusInnerProperty); }
- private set { SetValue(CornerRadiusInnerProperty, value); }
- }
-
- public static readonly DependencyProperty CornerRadiusInnerProperty =
- DependencyProperty.Register("CornerRadiusInner", typeof(CornerRadius), typeof(ZGroupBox));
- #endregion
- #endregion
- #region Constructors
- static ZGroupBox()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(ZGroupBox), new FrameworkPropertyMetadata(typeof(ZGroupBox)));
- }
- #endregion
- #region Override方法
- #endregion
- #region Private方法
- #endregion
- }
- }
|