wpf样式引用

样式定义

<Window.Resources>
<Style x:Key="FocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

</Window.Resources>

<Grid>

<Button Style="{StaticResource FocusVisual}"/>//引用样式

</Grid>

//TargetType指定了这个样式是Button的样式,如果没有指定Key会对当前的所有Button的样式更改,指定了Key必须要在Button中引用该样式才生效

<Style TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid Background="Orange">
<ContentPresenter Content="{TemplateBinding Content}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

 

上一篇:基础UI控件:TextView、Button、EditText(安卓开发学习笔记————10)


下一篇:<button open-type=“getUserInfo“> 目前已经不支持,快乐的用wx.getUserProfile()吧