添加图像的按钮编程里面 [英] Adding an Image inside a Button programmatically
本文介绍了添加图像的按钮编程里面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在WPF:
<Button Width="24" Height="24" >
<Image Source="pack://application:,,,/res/x.png" VerticalAlignment="Center"/>
</Button>
我怎么能模仿这在C#?我找不到,增加了儿童按钮
类的任何方法。
推荐答案
按钮
是内容
控制,因此您只需要使用按钮
内容
属性
Button
is a Content
control so you just have to use the Buttons
Content
property
例如:
Button myButton = new Button
{
Width = 24,
Height = 24,
Content = new Image
{
Source = new BitmapImage(new Uri("image source")),
VerticalAlignment = VerticalAlignment.Center
}
};
这篇关于添加图像的按钮编程里面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文