通过资源设置控件颜色.
在资源文件中:
<style TargetType="{x:Name button1}">
<setter Property="ColorBrush" Value="Red"/>
</style>
<Window .... >
<Button Name="Button1" Content="Test Button" />
</Window>
Run Code Online (Sandbox Code Playgroud)
喜欢html中的css
<style>
#controlID
{
color:red;
}
</style>
<body>
<input id="button1" type="button" value="test button" />
</body>
Run Code Online (Sandbox Code Playgroud)
在 window.resources 中定义这样的样式
<Window.Resources>
<Style x:Key="btnStyleRed" TargetType="Button">
<Setter Property="Background" Value="Red"/>
</Style>
</Window.Resources>
Run Code Online (Sandbox Code Playgroud)
并仅在您要应用特定样式的按钮上使用此样式
<Button x:Name="btnLogin" Style="{StaticResource btnStyleRed}" Content="Login" Width="75" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5483 次 |
| 最近记录: |