Files
BeWoPlaner/BeWo/View/ImageButton.cs
2016-06-27 01:45:38 +02:00

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;
}
}
}
}