using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;


namespace BeWo.Controls
{
    public class ImageButton : Button
    {
        public static readonly DependencyProperty ImageSourceProperty;

        static ImageButton()
        {
            ImageSourceProperty = DependencyProperty.Register("ImageSource", typeof(ImageSource), typeof(ImageButton));
        }

        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            ImageSource test = this.ImageSource;

            Image img = this.FindName("ButtonImage") as Image;
            if (img != null)
            {
                img.Source = test;
            }
        }

        public ImageSource ImageSource
        {
            get
            {
                return (ImageSource)GetValue(ImageSourceProperty);
            }
            set
            {
                SetValue(ImageSourceProperty, value);
            }
        }
    }
}
