2011-08-06 172 views
-3

我對wpf有個疑問,我在button.so上保留了圖像,當我們點擊按鈕時應該將圖像設置爲背景圖像,我該怎麼辦?任何人有想法> 請讓我知道。如何在wpf中設置動態窗口背景圖像

感謝Adavance 開發

+3

如果你不表達你自己更清楚地瞭解你有什麼(可能提供代碼)和什麼你想要它很難幫助。 –

+0

按鈕上的圖像很好,不需要特殊操作。 –

回答

0

如果你需要把圖像作爲任何控制的背景(按鈕或網格,沒understancd你),只需設置,在代碼中,背景屬性設置爲一個圖像刷與您的圖像的ImageSource。

0

該代碼可用於按鈕,編輯...

Button button = new Button(); 
button.Margin = new Thickness(220, -880, 0, 0); 
button.Width = w; 
button.Height = h; 
///////////////////////////////////////////////////////// 
ImageBrush berriesBrush = new ImageBrush(); 
berriesBrush.ImageSource = new BitmapImage(new Uri(@"Image/country.PNG", UriKind.Relative)); 
button.Background = berriesBrush; 
button.BorderThickness = new Thickness(0); 

這可能你......