首页 新闻 赞助 找找看

WPF 我创建一个类让他继承Button类

0
悬赏园豆:10 [已关闭问题] 关闭于 2016-07-06 13:42

我创建一个类让他继承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);
    }
View Code
WPF
蒙幸的主页 蒙幸 | 初学一级 | 园豆:95
提问于:2016-07-06 13:39
< >
分享
所有回答(1)
0
1      <Style TargetType="{x:type namespace:Button_M}">
2          <Setter/>
3          <Setter/>
4          <Setter/>
5       </Style>

 

Darren.Dai | 园豆:329 (菜鸟二级) | 2016-08-03 15:20
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册