C# Silverlight:更改应用程序中所有按钮的颜色

C# Silverlight:更改应用程序中所有按钮的颜色,c#,silverlight,C#,Silverlight,我是silverlight的新手。我想知道如何将应用程序中所有按钮的颜色更改为灰色。有没有办法定义一个从Button类继承的用户控件,然后像在windows窗体中那样全局使用它?试试这个 在您的内部App.XAML为按钮添加样式 <Application.Resources> <Style TargetType="Button"> <Setter Property="Background" Value="Gray"/>

我是silverlight的新手。我想知道如何将应用程序中所有按钮的颜色更改为灰色。有没有办法定义一个从Button类继承的用户控件,然后像在windows窗体中那样全局使用它?

试试这个

在您的内部
App.XAML
为按钮添加样式

 <Application.Resources>
        <Style TargetType="Button">
            <Setter Property="Background" Value="Gray"/>
        </Style>
 </Application.Resources>

现在,当您在主窗口中声明一个按钮时,它的背景颜色将是灰色的

 <Button Content="Sample Button"/>

创建一个文件themes/generic.xaml并将您的按钮样式放在那里:

<Style TargetType="Button">
  <Setter Property="Background" Value="Gray"/>
</Style>

您可以在声明了
按钮的位置共享您的
App.XAML
XAML
吗?