123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- 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);
- }
- }
- /// <summary>
- /// button的样式
- /// </summary>
- public Style ButtonStyle
- {
- get
- {
- return GetValue(ButtonStyleProperty) as Style;
- }
- set
- {
- SetValue(ButtonStyleProperty, value);
- }
- }
- }
- }
|