Search code examples
wpfpathheightwidth

Height and Width of path data


I am new to WPF and have a Path data like:

M44.3364,36.7461C42.2004,42.9021,36.3504,47.3241,29.4644,47.3241C20.7724,47.3241,13.7244,40.2761,13.7244,31.5851

Now I want to get height and width of this path data, how to do it?


Solution

  • You may get the Bounds of the Path's Data:

    <Path x:Name="path" Stroke="Black"
          Data="M44.3364,36.7461C42.2004,42.9021,36.3504,47.3241,29.4644,47.3241C20.7724,47.3241,13.7244,40.2761,13.7244,31.5851"/>
    

    Code:

    Rect bounds = path.Data.Bounds;