locked
Evaluating the size of an element set to auto (Liam Coffey) - 2/15/2007 9:15 AM PST RRS feed

  • Question

  • By: Liam Coffey

    I am looking for a way to measure the Height or Width of a element that is 
    set to automatic (Double.NaN).
    If you set the property .Height = Double.NaN and you add some child elements 
    to that parent one then how do you get the size?
    If you read the .Height property it still reads Double.NaN... Now I know 
    this is what it is supposed to do, but I cannot find any other property that 
    will tell me what I need.
    Is there a way in .net to measure the height of the element? I have looked 
    everywhere and cannot find anything relating to such a thing.
    
    Tuesday, February 19, 2008 8:13 PM

Answers

  • By: Jen Rowe [MSFT]


    You can try ActualHeight and ActualWidth. These are dependency properties
    that will give you the calculated value baed on the layout system. You will
    need to reference these programtically.

    See
    http://msdn2.microsoft.com/en-us/library/system.windows.frameworkelement.actualheight.aspx

    Jen Rowe(MSFT), Expression Blend
    "Content is provided "AS IS" with no warranties and confers no rights.


    "Liam Coffey" <LiamCoffey@discussions.microsoft.com> wrote in message
    news:01FE80C2-42BF-443B-9463-E50E181541A8@microsoft.com...
    >I am looking for a way to measure the Height or Width of a element that is
    > set to automatic (Double.NaN).
    > If you set the property .Height = Double.NaN and you add some child
    > elements
    > to that parent one then how do you get the size?
    > If you read the .Height property it still reads Double.NaN... Now I know
    > this is what it is supposed to do, but I cannot find any other property
    > that
    > will tell me what I need.
    > Is there a way in .net to measure the height of the element? I have looked
    > everywhere and cannot find anything relating to such a thing.
    >

    Tuesday, February 19, 2008 11:47 PM