I have small doubt in wpf,i kept image on button.so when we click on button that image should be set as back ground?what should i do? an开发者_StackOverflow中文版y one have idea> please let me know.
Thanks in Adavance Developer
If you need to put an image as a background of any control (button or grid, didn't understancd you), just set, in code, the Background property to an ImageBrush with an ImageSource of your image.
This code is for button, edit it ...
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);
This might you ...
精彩评论