I need to create this style using c# code to generate dynamic points for polygon instead of static ones in xaml tags.
<Style x:Key="Mystyle" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid >
<Polygon Points="0,0 0,100 50,200" Fill="{TemplateBinding Background}"
Stroke="{TemplateBinding BorderBrush}" DataContext="{Binding}" />
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
I hope this will help you to give the idea how to do. And yes you can set all bindings in code behind like Fill of polygon and Content of ContentPresenter .