使用WPF封装了一个简单的ImageButton自定义控件,加入常态、划过、按下、禁用状态属性,可设置相应的图标。参考链接:https://blog.youkuaiyun.com/elie_yang/article/details/81870694
1、ImageButton自定义控件类
public class UCImageButton : Button
{
static UCImageButton()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(UCImageButton), new FrameworkPropertyMetadata(typeof(UCImageButton)));
}
#region Properties
public static DependencyProperty NormalImageProperty = DependencyProperty.Register("NormalImage", typeof(ImageSource), typeof(UCImageButton), new PropertyMetadata(null));
public ImageSource NormalImage
{
get { return (ImageSource)GetValue(NormalImageProperty); }
set { SetValue(NormalImageProperty, value); }
}
public static readonly DependencyP