Bret
Bret

Reputation: 922

Collapsible Window with WPF

How can I make a window in WPF that looks like the attached (notice the "collapse" button to the left of the minimize/maximize buttons)? I've sifted through the documentation at length to no avail. Any insight into this matter is much appreciated :)

alt text http://www.study.en0de.com/cwindow.jpg

Upvotes: 2

Views: 316

Answers (1)

Josh
Josh

Reputation: 69282

There's nothing really specific to WPF for doing this. You have to resort to Win32 P/Invoke to draw in the non-client area. Fortunately, searching for topics related to this is very easy if you search for WM_NCPAINT ( google / stackoverflow ) but unfortunately, it's not trivial to do. So I don't think it would be very helpful for my to write up a complete example when there's many C# examples available here.

The only thing specific to WPF that you need to do is use the HwndSource class to specify a hook procedure to process the message.

protected override void OnSourceInitialized(EventArgs e)
{
    base.OnSourceInitialized(e);
    var source = (HwndSource)PresentationSource.FromVisual(this);
    source.AddHook(WndProc); // a function to process windows messages
}    

Upvotes: 3

Related Questions