在主窗口C#visual studio的背景中的图像 [英] Image in the backgroud of mainwindow C# visual studio

查看:109
本文介绍了在主窗口C#visual studio的背景中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我想把照片作为我的wpf主窗口应用程序的背景。

(我正在使用visual studio 2010,该应用程序将用于Windows专业版3平板电脑)。

请问有人帮我一个tutoriel或者一个拳头吗?

谢谢



我的尝试:



我已经尝试运行此代码(ifound在互联网上):



Hello everyone,

I want to put a photo as a background of my wpf mainwindow application.
( i am using visual studio 2010 and the app is destinated to a windows pro 3 tablet ).
Could anybody help me with a tutoriel or a pist please ?
Thank you

What I have tried:

I have already tried running this code ( ifound on internet ) :

ImageBrush myBrush = new ImageBrush();
Image image = new Image();
image.Source = new BitmapImage(new Uri(@"ms-appx:///Assets/poste_image.bmp"));
myBrush.ImageSource = image.Source;
Grid.Background = myBrush;



但这不起作用:/


But this doesn't work :/

推荐答案

把它放在你的XAML窗口中:

Put this in your XAML window:
<Window.Background>
    <ImageBrush x:Name="BackgroundImage1" ImageSource="Images/BackgroundImage.png" />
</Window.Background>





或控件:



Or for a control:

<my:ListViewCustom x:Name="ListView1">

    <my:ListViewCustom.Background>
        <ImageBrush x:Name="BackgroundImage1" ImageSource="Images/BackgroundImage.png" />
    </my:ListViewCustom.Background>


这篇关于在主窗口C#visual studio的背景中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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