user275587
user275587

Reputation: 690

How to get a tool window title bar height in WPF?

WPF includes the title bar height in the total window height instead of using only the client content area height.

I'm aware of the SystemParameters.CaptionHeight property and the SystemParameters.WindowCaptionHeight property but they both return the height of a regular window title bar. This is not the correct value for a tool window because the title bar is smaller for this type of window. I need something like SystemParameters.ToolWindowCaptionHeight

Thanks.

Upvotes: 2

Views: 5392

Answers (2)

Thomas Levesque
Thomas Levesque

Reputation: 292415

The size of the client area is the actual size of the window's root element :

public double ClientWidth
{
    get { return ((FrameworkElement)this.Content).ActualWidth; }
}

public double ClientHeight
{
    get { return ((FrameworkElement)this.Content).ActualHeight; }
}

Upvotes: 5

Lars Truijens
Lars Truijens

Reputation: 43595

You could fall back to System.Windows.Forms.SystemInformation.ToolWindowCaptionHeight. Although it is in the WinForms namespace, it is hardly a WinForms only class.

Upvotes: 1

Related Questions