Wil*_*son 7 c# wpf children button
在WPF中:
<Button Width="24" Height="24" >
<Image Source="pack://application:,,,/res/x.png" VerticalAlignment="Center"/>
</Button>
Run Code Online (Sandbox Code Playgroud)
我怎样才能在C#中模仿这个?我在Button类中找不到添加子项的任何方法.
sa_*_*213 25
Button是一个Content控件,所以你只需要使用该Buttons Content属性
例:
Button myButton = new Button
{
Width = 24,
Height = 24,
Content = new Image
{
Source = new BitmapImage(new Uri("image source")),
VerticalAlignment = VerticalAlignment.Center
}
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17486 次 |
| 最近记录: |