xaml border style
I create style for buttons:
<Style TargetType="{x:Type Button}">
<Setter Property="Background" Value="#8A88E1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<Ellipse Fill="{TemplateBinding Background}"/>
<ContentPresenter HorizontalAlignment="Center"
VerticalAli开发者_开发问答gnment="Center"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
It all OK. Now I want to write part of the style that would be looked around the ellipse boundary.
Erno beat me to the answer, but here's an example:
<Style TargetType="{x:Type Button}">
<Setter Property="Background" Value="#8A88E1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<Ellipse Fill="{TemplateBinding Background}" Stroke="..." StrokeThickness="..." />
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
You should be able to bind the Stroke to the parent BorderBrush but I haven't tested it: Stroke="{TemplateBinding BorderBrush}". However, you won't be able to directly bind StrokeThickness to the parent BorderThickness as they're two different types (Ellipse.StrokeThickness is uniform and a simple double value whereas Button.BorderThickness is of type Thickness.).
There are two options:
Set the Stroke and StrokeThickness of the ellipse or
Add a template to the border and use an ellipse in the template.
Let me know if you need help with these.
加载中,请稍侯......
精彩评论