如何在c#代码中更改windows store应用程序的背景图像?

时间:2013-04-19 19:54:30

标签: c# windows windows-store-apps windows-store

我想使用C#更改Windows应用商店应用的背景图片。 我想要更改背景图像,类似于以下伪代码:

This.Background.ImageSource= "dracula-128.png";

1 个答案:

答案 0 :(得分:2)

一种方法是创建ImageBrush,设置其ImageSource属性,然后将其分配给后台。 (代码根据评论更新)

//BitmapImage class is within this namespace
using Windows.UI.Xaml.Media.Imaging;    

ImageBrush ib = new ImageBrush();
ib.ImageSource = new BitmapImage(new Uri(@"ms-appx:///dracula-128.png", UriKind.RelativeOrAbsolute));   
this.Background = ib;
相关问题