我创建一个类让他继承Button类,然后添加了两个属性。如何给这个控件类写样式,并在样式中能获取到新添加的两个属性的值
public class Button_M:Button { public string EnableImaUri { get { return (string)GetValue(EnableImaUriProperty); } set { SetValue(EnableImaUriProperty, value); } } public static readonly DependencyProperty EnableImaUriProperty = DependencyProperty.Register("EnableImaUri", typeof(string), typeof(Button_M), null); public string DisEnableImaUri { get { return (string)GetValue(DisEnableImaUriProperty); } set { SetValue(DisEnableImaUriProperty, value); } } public static readonly DependencyProperty DisEnableImaUriProperty = DependencyProperty.Register("DisEnableImaUri", typeof(string), typeof(Button_M), null); }
1 <Style TargetType="{x:type namespace:Button_M}"> 2 <Setter/> 3 <Setter/> 4 <Setter/> 5 </Style>