2011-08-06 120 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); 

这可能你......