Ask a questionAsk a question
 

AnswerWindow Client Size?

  • Friday, September 21, 2007 1:26 PMStaticPhilly Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    hi,

     

    can anyone tell me if its possable to get the size of the window client area? and if so how?

     

    cheers,

    Philly

Answers

  • Friday, September 21, 2007 7:29 PMHua Wang - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    You can get the client size via the the window visual tree root’s ActualWidth/Height, e.g,

     

    FrameworkElement f =  VisualTreeHelper.GetChild(window, 0) as FrameworkElement;

    f.ActualWidth/Height

     

    In Window’s default style, the visual tree root is a Border.

     

    If your content is FrameworkElement and its layout behavior is sized to container, you can get the ActualWidth/Height directly of window.Content.

All Replies

  • Friday, September 21, 2007 5:33 PMMarlon GrechMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    what do you mean by Window client area??? is it te size of the window including the titlebar?
  • Friday, September 21, 2007 7:29 PMHua Wang - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    You can get the client size via the the window visual tree root’s ActualWidth/Height, e.g,

     

    FrameworkElement f =  VisualTreeHelper.GetChild(window, 0) as FrameworkElement;

    f.ActualWidth/Height

     

    In Window’s default style, the visual tree root is a Border.

     

    If your content is FrameworkElement and its layout behavior is sized to container, you can get the ActualWidth/Height directly of window.Content.