Canvas.GetTop() returning NaN

I've run into a similar situation (NaN), but in a different context. As I recall, it had something to do with how the element was positioned in the container.

Sorry I couldn't provide more help, but maybe this will provide some guidance.


It seems the general consensus is the Canvas.GetTop(x) returns 'Nan' if the value is not explictly set (even tho I do explicitly set it I still sometimes get that result).

An alternative method I'm now using is

Vector offset = VisualTreeHelper.GetOffset(fElement);

which returns the position of fElement within it's container.

Tags:

C#

Wpf