将图像绘制为按钮内容 [英] Draw an image as Button Content
本文介绍了将图像绘制为按钮内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好! :)
我对Blend和WPF很新,我有一个问题。
Hi all! :)
I'm very new to Blend and WPF, and I have a question.
是否可以直接在Blend中绘制图像以用作特定Button的内容属性?
如果没有,是否可以将.wmf文件用作Image.Source?
Is it possible to draw an image directly in Blend to use as Content property of a particular Button?
If not, is it possible to use a .wmf file as an Image.Source?
非常感谢高级!
推荐答案
当然可以这样做。
你必须为此创建一个DataTemplate
Sure you can do that.
You have to Create a DataTemplate for that
<UserControl.Resources>
<DataTemplate x:Key="DataTemplate1">
<Grid>
<Image HorizontalAlignment="Left" Height="..." VerticalAlignment="Top" Width="..." Source="..."/>
</Grid>
</DataTemplate>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<Button Content="Button" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" ContentTemplate="{StaticResource DataTemplate1}"/>
</Grid>
这篇关于将图像绘制为按钮内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文