42 lines
1.0 KiB
C#
42 lines
1.0 KiB
C#
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Media;
|
|
|
|
namespace BeWo.View
|
|
{
|
|
public class ImageButton : Button
|
|
{
|
|
public static readonly DependencyProperty ImageSourceProperty;
|
|
|
|
static ImageButton()
|
|
{
|
|
ImageSourceProperty = DependencyProperty.Register("ImageSource", typeof(ImageSource), typeof(ImageButton));
|
|
}
|
|
|
|
public ImageSource ImageSource
|
|
{
|
|
get
|
|
{
|
|
return (ImageSource)this.GetValue(ImageSourceProperty);
|
|
}
|
|
|
|
set
|
|
{
|
|
this.SetValue(ImageSourceProperty, value);
|
|
}
|
|
}
|
|
|
|
protected override void OnRender(DrawingContext drawingContext)
|
|
{
|
|
base.OnRender(drawingContext);
|
|
|
|
ImageSource test = this.ImageSource;
|
|
|
|
Image img = this.FindName("ButtonImage") as Image;
|
|
if (img != null)
|
|
{
|
|
img.Source = test;
|
|
}
|
|
}
|
|
}
|
|
} |