The folloging code will give a Red background to all the Buttons in the Window provided if we didnt set the ButtonBackground explicitly
< Window.Resources >
< Style x:key="{x:Type Button}" TargeType="{x:Type Button}" >
< Setter Property ="Background" Value ="Red"/ >
< /Style >
< /Window.Resources >
C# Code
Style sty = new Style(typeof(Button));
Setter set = new Setter(Button.BackgroundProperty , Brushes.Red);
sty.Setters.Add(set);
Resources.Add(typeof( Button), sty);
Hi Joy,
ReplyDeleteNice example. :)
Quite helpful.. Thank you.. :)
ReplyDelete