2011-09-21 76 views
3

我需要將背景設置爲Stackpanel到資源中的某個圖像。
我知道,我應該設置背景如下:在c中設置一個堆疊面板的背景圖像#

Stack.Background= image; // don't know of what type the image should be how to set it 

任何幫助表示讚賞,

+0

您是否嘗試過使用ImageBrush並收到某種錯誤?或者你問如何做到這一點? – ajmccall

回答

5
string fileName = "/Background.png"; 
BitmapImage image = new BitmapImage(new Uri(fileName, UriKind.Relative)); 
ImageBrush brush = new ImageBrush(); 
brush.ImageSource = image; 
stack.Background = brush;