使用C#在WPF中的网格上设置背景图像 [英] Set background image on grid in WPF using C#

查看:121
本文介绍了使用C#在WPF中的网格上设置背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题:我想通过后面的代码设置网格的图像。

I have a problem: I want to set the image of my grid through code behind.

有人可以告诉我该怎么做吗?

Can anybody tell me how to do this?

推荐答案

Did您会忘记背景属性。画笔应该是可以将ImageSource设置为图像路径的ImageBrush。

Did you forget the Background Property. The brush should be an ImageBrush whose ImageSource could be set to your image path.

<Grid>
    <Grid.Background>
        <ImageBrush ImageSource="/path/to/image.png" Stretch="UniformToFill"/>
    </Grid.Background>

    <...>
</Grid>

这篇关于使用C#在WPF中的网格上设置背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆