Silverlight: Changing color of all buttons in the application
I am new to silverlight. I would li开发者_如何学运维ke to know how to change the color all the buttons in my application to gray. Is there any way to define a user control that inherits from Button class and then use that globally as done in windows forms?
Try this
inside you App.XAML
add a style for button
<Application.Resources>
<Style TargetType="Button">
<Setter Property="Background" Value="Gray"/>
</Style>
</Application.Resources>
Now when you will declare a button in let's say in MainWindow, its background color will be Gray
<Button Content="Sample Button"/>
Create a file themes/generic.xaml and put your button style there:
<Style TargetType="Button">
<Setter Property="Background" Value="Gray"/>
</Style>
精彩评论