WPF: How to autosize Path to its container?

前端 未结 4 560
闹比i
闹比i 2021-01-17 09:37

I have a Path that must resize to its StackPanel container.


    

        
4条回答
  •  孤城傲影
    2021-01-17 10:18

    If you want this with a constant stroke width that isn't scaled, you can use a custom Shape. Shapes in WPF effectively encapsulate scaling a geometry and applying a stroke afterwards, which means you can have a scaled path that also always has the same stroke width.

    Creating a shape is quite easy:

    public class MyShape : Shape
    {
      public override Geometry DefiningGeometry
      {
        get
        {
          // Create your geometry here
        }
      }
    }
    

提交回复
热议问题