Overriding ActualWidth and ActualHeight dependency properties

563 Views Asked by At

I have a custom line shape with start and end point. The ActualWidth and ActualHeight properties however do not return the correct value, that is the difference between the points. Is there a way to override these properties in the derived class, and how would you go about doing it. I need to use the ActualWidth and ActualHeight properties since I am using an algorithm which uses those properties for other shapes.

1

There are 1 best solutions below

0
On BEST ANSWER

You can't override ActualWidth and ActualHeight, they are computed:

The value is set by the layout system itself, based on an actual rendering pass

So, what you should do instead is to change how your shape behaves during rendering. Either by the way you override DefiningGeometry (assuming your shape is actually Shape) or by overriding MeasureOverride().