using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
namespace cs2_chs
{
///
/// App.xaml 的交互逻辑
///
public partial class App : Application
{
}
public class ImageButton : System.Windows.Controls.Button
{
///
/// 图片
///
public static readonly DependencyProperty ImageProperty = DependencyProperty.Register("Image", typeof(ImageSource), typeof(ImageButton),
new PropertyMetadata(null));
///
/// 图片的宽度
///
public static readonly DependencyProperty ImageWidthProperty = DependencyProperty.Register("ImageWidth", typeof(double), typeof(ImageButton),
new PropertyMetadata(double.NaN));
///
/// 图片的高度
///
public static readonly DependencyProperty ImageHeightProperty = DependencyProperty.Register("ImageHeight", typeof(double), typeof(ImageButton),
new PropertyMetadata(double.NaN));
///
/// 构造函数
///
static ImageButton()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(ImageButton),
new System.Windows.FrameworkPropertyMetadata(typeof(ImageButton)));
}
///
/// 设置图片
///
public ImageSource Image
{
get
{
return GetValue(ImageProperty) as ImageSource;
}
set
{
SetValue(ImageProperty, value);
}
}
///
/// 图片宽度(属性)
///
public double ImageWidth
{
get
{
return (double)GetValue(ImageWidthProperty);
}
set
{
SetValue(ImageWidthProperty, value);
}
}
///
/// 图片高度(属性)
///
public double ImageHeight
{
get
{
return (double)GetValue(ImageHeightProperty);
}
set
{
SetValue(ImageHeightProperty, value);
}
}
}
}