Files
DP44/Common/DTS.CommonCore/Utils/ImageButton.cs
2026-04-17 14:55:32 -04:00

53 lines
1.2 KiB
C#

using System.Windows.Controls;
using System.Windows.Media;
namespace DTS.Common.Utils
{
public class ImageButton : Button
{
private readonly Image _image;
private readonly TextBlock _textBlock;
public ImageButton()
{
var panel = new StackPanel
{
Orientation = Orientation.Vertical,
Margin = new System.Windows.Thickness(10)
};
_image = new Image {Margin = new System.Windows.Thickness(0, 0, 0, 0), Stretch = Stretch.Fill};
panel.Children.Add(_image);
_textBlock = new TextBlock();
panel.Children.Add(_textBlock);
Content = panel;
}
private ImageSource _source;
public ImageSource Source
{
get => _source;
set
{
_source = value;
_image.Source = _source;
}
}
private string _imageText;
public string ImageText
{
get => _imageText;
set
{
_imageText = value;
_textBlock.Text = _imageText;
}
}
}
}