Windows phone 7 将stackpanel的背景设置为c语言中的图像#
我需要将堆栈面板的背景设置为参考资料中的某个图像。Windows phone 7 将stackpanel的背景设置为c语言中的图像#,windows-phone-7,Windows Phone 7,我需要将堆栈面板的背景设置为参考资料中的某个图像。 我知道我应该设置如下背景: Stack.Background= image; // don't know of what type the image should be how to set it 非常感谢您的帮助。属于画笔类型,您需要创建一个画笔,以便在StackPanel上显示图像。您是否尝试过使用ImageBrush,但遇到了某种错误?还是你在问怎么做? string fileName = "/Background.png";
我知道我应该设置如下背景:
Stack.Background= image; // don't know of what type the image should be how to set it
非常感谢您的帮助。属于画笔类型,您需要创建一个画笔,以便在StackPanel上显示图像。您是否尝试过使用ImageBrush,但遇到了某种错误?还是你在问怎么做?
string fileName = "/Background.png";
BitmapImage image = new BitmapImage(new Uri(fileName, UriKind.Relative));
ImageBrush brush = new ImageBrush();
brush.ImageSource = image;
stack.Background = brush;