Here you go
I attempted to solve the triangle with two approach
result

Viewbox approach
if you are interested in rendering a triangle of size of a control then this could be your choice
<Grid>
<Viewbox Stretch="Fill">
<Path Data="M 1.5,0 L 3,3 0,3 Z"
Width="3" Height="3"
Fill="Gray" />
</Viewbox>
</Grid>
above approach will render a triangle and will resize to the size of the parent control via Viewbox, additionally you can add a rotation transform to path and rotate the triangle as per your needs.
this approach is recommended if you simply need a triangle no matter how
Polygon using Converter
<Grid xmlns:l="clr-namespace:CSharpWPF"
x:Name="control">
<Grid.Resources>
<l:ElementToTrianglePointsConverter x:Key="ElementToTrianglePointsConverter" />
</Grid.Resources>
<Polygon Points="{Binding ElementName=control, Converter={StaticResource ElementToTrianglePointsConverter}}"
FillRule="Nonzero"
Fill="Gray" />
</Grid>
converter
namespace CSharpWPF
{
public class ElementToTrianglePointsConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
FrameworkElement element = value as FrameworkElement;
PointCollection points = new PointCollection();
Action fillPoints = () =>
{
points.Clear();
points.Add(new Point(element.ActualWidth / 2, 0));
points.Add(new Point(element.ActualWidth, element.ActualHeight));
points.Add(new Point(0, element.ActualHeight));
};
fillPoints();
element.SizeChanged += (s, ee) => fillPoints();
return points;// store;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
above approach is little buggy, I always have to re-size the window it before I can see the triangle. I can see it by default at design time but not at runtime unless i resize the window. although polygon have points in it but not rendered, not sure why? need to investigate the issue
Converterscan help you here, you can still bindPointsproperty ofPolygonhowever they may not respond to change. - pushpraj