3
我需要將背景設置爲Stackpanel到資源中的某個圖像。
我知道,我應該設置背景如下:在c中設置一個堆疊面板的背景圖像#
Stack.Background= image; // don't know of what type the image should be how to set it
任何幫助表示讚賞,
我需要將背景設置爲Stackpanel到資源中的某個圖像。
我知道,我應該設置背景如下:在c中設置一個堆疊面板的背景圖像#
Stack.Background= image; // don't know of what type the image should be how to set it
任何幫助表示讚賞,
string fileName = "/Background.png";
BitmapImage image = new BitmapImage(new Uri(fileName, UriKind.Relative));
ImageBrush brush = new ImageBrush();
brush.ImageSource = image;
stack.Background = brush;
StackPanel.Background的類型是刷的,你會需要,以顯示圖像創建ImageBrush在StackPanel上。
您是否嘗試過使用ImageBrush並收到某種錯誤?或者你問如何做到這一點? – ajmccall