i'm trying to create a Custom Shape (Triangle) but I can't find the right way to get a Custom Shape working.
In WPF I'm used to overriding DefiningGeometry, but using WinUI 3 there is nothing like it.
Using WPF:
public class Triangle : Shape
{
private double size;
public static readonly DependencyProperty SizeProperty = DependencyProperty.Register("Size", typeof(Double), typeof(Triangle));
public Triangle(){}
public double Size
{
get { return (double)this.GetValue(SizeProperty); }
set { this.SetValue(SizeProperty, value); }
}
protected override Geometry DefiningGeometry
{
get {
Point p1 = new Point(0.0d,0.0d);
Point p2 = new Point(this.Size, 0.0d);
Point p3 = new Point(this.Size / 2, -this.Size);
List<PathSegment> segments = new List<PathSegment>(3);
segments.Add(new LineSegment(p1,true));
segments.Add(new LineSegment(p2, true));
segments.Add(new LineSegment(p3, true));
List<PathFigure> figures = new List<PathFigure>(1);
PathFigure pf = new PathFigure(p1, segments, true);
figures.Add(pf);
Geometry g = new PathGeometry(figures, FillRule.EvenOdd, null);
return g;
}
}
}
How can i do this using WinUI 3?