如何在XAML代码中设置Appli.Path [英] How to set the Appli.Path in XAML code
问题描述
HI Code Projectees,
我是WPF的新手,这是我的问题,我想在一个按钮中设置图像,以便任何人都可以告诉我如何使用XAML代码设置图像路径..我知道如何在C#代码中进行设置.认为我的查询还可以..
预先感谢,
JnFred
HI Code Projectees,
I''m new to WPF and here is my issue, I want to set the image in a button so can anyone tell how could i set the image path using XAML code..I knew how to make that in C# code..I think my queries are OK..
Thanks in advance,
JnFred
推荐答案
您只需要使用图像作为按钮的内容,就像这样
You just need to use the image as the content for the button, something like this
<Button Grid.Row="2">
<Button.Content>
<Image Source="your image file path"/>
</Button.Content>
</Button>
关于您的评论,我唯一知道的方法是在应用程序中包含图像(右键单击您的项目,然后选择添加退出文件,然后选择您的图像),然后设置图像文件建立对内容的操作.然后您可以为图像使用相对地址,例如
With regard to your comment, the only way I know how to do that is to include the image in your application(right click your project, then select add exiting file, and select your image), and then set the image file''s Build Action to content. Then you can use a relative address for the image like this
<Button Grid.Row="2">
<Button.Content>
<Image Source="image.jpg"/>
</Button.Content>
</Button>
[/编辑]
希望对您有帮助
[/Edit]
Hope this helps
这篇关于如何在XAML代码中设置Appli.Path的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!