using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Input; namespace FWindSoft.Wpf.Controls { public class DescriptionDecorator: ContentControl { public static readonly DependencyProperty DescriptionProperty = DependencyProperty.Register("Description", typeof(object), typeof(DescriptionDecorator), new PropertyMetadata(null, null)); static DescriptionDecorator() { DefaultStyleKeyProperty.OverrideMetadata(typeof(DescriptionDecorator), new FrameworkPropertyMetadata(typeof(DescriptionDecorator))); try { HorizontalContentAlignmentProperty.OverrideMetadata(typeof(DescriptionDecorator), new FrameworkPropertyMetadata(HorizontalAlignment.Stretch, null)); VerticalContentAlignmentProperty.OverrideMetadata(typeof(DescriptionDecorator), new FrameworkPropertyMetadata(VerticalAlignment.Center, null)); } catch (Exception ex) { } } public DescriptionDecorator() { //this.HorizontalContentAlignment = HorizontalAlignment.Stretch; //this.VerticalContentAlignment = VerticalAlignment.Center; } public object Description { get { return base.GetValue(ContentControl.ContentProperty); } set { base.SetValue(ContentControl.ContentProperty, value); } } } public class ButtonDecorator : DescriptionDecorator { public static readonly DependencyProperty ButtonStyleProperty= DependencyProperty.Register("ButtonStyle", typeof(Style), typeof(ButtonDecorator), new FrameworkPropertyMetadata(null)); public static readonly DependencyProperty CommandProperty = DependencyProperty.Register("Command", typeof(ICommand), typeof(ButtonDecorator), new FrameworkPropertyMetadata(null)); public static readonly DependencyProperty CommandParameterProperty = DependencyProperty.Register("CommandParameter", typeof(object), typeof(ButtonDecorator), new FrameworkPropertyMetadata(null)); static ButtonDecorator() { DefaultStyleKeyProperty.OverrideMetadata(typeof(ButtonDecorator), new FrameworkPropertyMetadata(typeof(ButtonDecorator))); } public ICommand Command { get { return (ICommand)base.GetValue(CommandProperty); } set { base.SetValue(CommandProperty, value); } } public object CommandParameter { get { return base.GetValue(CommandParameterProperty); } set { base.SetValue(CommandParameterProperty, value); } } /// /// button的样式 /// public Style ButtonStyle { get { return GetValue(ButtonStyleProperty) as Style; } set { SetValue(ButtonStyleProperty, value); } } } }