I’ve designed a style for a UserControl in various shapes eg Star, Ball, sky etc. All these shapes are designed using a path. I need read the content of the usercontrol using the style and adjust the width and height and display the content.
<Style TargetType="{x:Type UserControl}">
<Setter Property="Background" Value="#CCC4C4" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type UserControl}">
<Path
Data="F1M37.3,41.5L24.0,34.8 10.7,41.4 13.2,27.3 2.5,17.3 17.4,15.3 24.0,2.5 30.6,15.3 45.5,17.4 34.7,27.3 37.3,41.5z"
Fill="White"
Height="{TemplateBinding Height}"
Width="{TemplateBinding Width}"
Stroke="#FFC4A000"
StrokeMiterLimit="4"
StrokeThickness="1">
</Path>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
You can use a ContentControl, its a
Containerthat can be filled with individual content.Here’s an example:
EDIT:
If you want the star to resize to its available space, use Stretch = Fill, instead of the with and height binding (changed that above).