Sometime back I had posted about the Custom Window Control but was a little lazy in putting up the source code as it was part of a bigger library. I have finally taken it out, changed the namespaces and removed some dependencies. Feel free to use the code as you wish. If you add any extra cool stuff, I would love to hear back
The zip contains the GlassWindow control with the Vista and the MacOSX window templates. It should give you a good idea about creating your own templates.
The executable has two XAML Windows for the Vista and MacOSX style. By switching the StartupUri in App.xaml you can test both.
![]()
![]()
This is now part of the FluidKit project

Hi there,
I have noticed the same slow behavior on Vista machines. On the XP box it was much faster. I think it may be related to the Display Driver, yet to confirm though.
The GlassWindow is very cool! However, I also have 1 problem with it and it is IMO major. The problem lies in the fact that the Custom Title Bar is not recognized by tools like UISpy from the Windows SDK. We originally discovered the problem while demoing a WPF application based on the GlassWindow using it’s custom titlebar and we were using a tool called GotoMeeting.com to run the demo remotely. The problem was when my customer joined the meeting they could not see the WPF application at all. They could see my desktop and all other windows, but they could not see it at all. Turns out that the GotoMeeting Client app can’t find the window because there is something different about the custom TitleBar as compared with the standard WindowsXP titlebar. If you look in a Microsoft UI inspector tool like UISpy you will find that it can’t see it either. Here is what you see:
"window" "GlassWindow Control – Windows Vista style"
+ "image" ""
+ "button" ""
+ "button" ""
+ "button" ""
but what I should see is:
"window" "GlassWindow Control – Windows Vista style"
+ "title bar" "GlassWindow Control – Windows Vista style"
+ "image" ""
+ "button" ""
+ "button" ""
+ "button" ""
Does anyone know what the problem is and/or how to fix this?
Hi
I am using the GlassWindow for a project I am working on, and I like it very much.
One problem I am having with it is that I cannot get it to skin properly. I want to keep the Vista Skin as default style and allow skin assemblies to "OverridesDefaultStyle" using ResourceDictionaries and change the look, without having to use style keys. Now I can do this with all other controls I have, but I simply cannot make it happen with the GlassWindow.
I am testing this by copying the style from GlassWindow.generic.xaml and modify a few properties like background colour to see if it has any affect, but the OnTemplateChanged event is never fired on the GlassWindow like it is on the other controls I have.
Do you have any ideas on how to do this with the glass window? I have spent far to much time trying to figure this out and I am hoping you could help me shed some light on this.
Regards Lau
Thanks for the great update on the issue with WindowsFormsHost…I am glad you like the GlassWindow control and finding it useful for your projects. Fortunately for me the work that I do doesn’t require me to resort to Winforms integration since its pure WPF
However the links you have given will definitely be useful when I do have to go that direction.
Thanks again!
Hi Pavan,
I just wanted to update you on the WindowsFormsHost issue. I finally solved this by using Peter Antal’s approach, here:
http://blogs.msdn.com/pantal/archive/2007/07/31/managed-directx-interop-with-wpf-part-2.aspx
and my subsequent discussion with him here:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2055201&SiteID=1
Using his Airspace approach, I was able to hover my WinForms control over my WPF window, allowing the WPF window to use transparency, which gave me the glass I wanted AND my control shows up.
This is the ONLY way to solve this problem due to Airspace issues – the WindowsFormsHost will NEVER paint its contents if AllowsTransparency=True – this is because WPF passes all Transparency windows directly to DirectX for rendering (in order to achieve per-pixel transparency), meaning the WinForms controls are never sent a paint message.
This solution will work for me, although there are some resize performance issues on the WinForms control. I can work around that though.
Thanks for the amazing Glass Window – my coworkers will be impressed. Makes the application look very professional.
To the poster who mentioned the maximize window bug – it’s not really a bug, it’s the way layered, style-less windows are designed to work in Windows. This is how full screen applications achieve being full screen. Lester’s MINMAXINFO approach solves the problem; I actually incorporated that piece of code into my project a week ago.
One note about Lester’s approach: If you’ve set the MinWidth/Height properties on your window, this method will cause them to not be used. You need to modify the WmGetMinMaxInfo method to set the mmi.ptMinSize.x and ptMinSize.y fields to the MinWidth and MinHeight properties of your window, otherwise this method will allow your window to become infinitely small.
I would add that info on his blog post but new comments are disabled.
Lester has a blog entry about this: http://blogs.msdn.com/llobo/archive/2006/08/01/Maximizing-window-_2800_with-WindowStyle_3D00_None_2900_-considering-Taskbar.aspx
It uses some Interop code to get it done.
Pavan
The ImageButton is part of the GlassButton control library. You should reference with a namespace and it should work. Let me know.
Thanks Patrick! I look forward to your solution. I am glad you are finding this control useful despite some pesky issues
Hi Pavan,
Ok, after too much time spent on the issue, the only way to fix it is to set AllowsTransparency explicitly to False on the Window. WindowsFormsHost simply does not paint anything if transparency is allowed, and there’s no avoiding the issue.
Of course, that means you lose the fancy transparency on the VistaWindow template, as well as getting quite alot of black boxes where the system simply decided not to paint because transparency is disabled.
So I’m going with the alternate approach – keep the object in memory, resize it manually when the container resizes, and simply put an Image where I wanted the WindowsFormsHost to go, and set the Image’s Source property to a snapshot of the control periodically.
Thanks for the great style! I’m going to see if I can whip up a couple that look nice; I’ll post a link if I get to it.
Hi Pavan,
First let me say – the more I look at this in my windows the more impressed I am. There are a couple of other frame-customization solutions out there but yours is by FAR the obviously superior one.
I’ve spent much of the day investigating the WindowsFormsHost problem and was about to give up and just capture a bitmap of my control and display it in WPF, and when I went to do so, I discovered that the problem all along is that the OnPaint event is not being called on the WinForms control. It DOES get called with a regular Window, however, so I think it has something to do with the subclassing.
Will investigate further…
I’ve run into something you probably didn’t think of, and I simply have no idea how to solve:
When mounting a WinForms control inside a WindowsFormsHost and then placing it into a window created using this library, the WinForms control is there, you can interact with it, you simply can’t SEE it. I have tried several different things to try to get the control to appear and it simply won’t.
Any ideas? I would love to use this approach to get rid of the normal (UGLY) title bar, but this is a non-starter for me. This WinForms control is the only one of its kind and its functionality is completely unique.
(Kein Name)…. I’m gonna write what I found on the web about this problem: "The WPF Frame control alters the way it renders based on the type of
content it is displaying. When it is displaying WPF Pages or loose XAML
it uses WPF’s rendering pipeline. When HTML is displayed the Frame uses
Internet Explorer for rendering. Internet Explorer uses traditional
GDI-based rendering. Thus when displaying HTML content you will
experience many of the rendering issues you also encounter when using a
HwndHost, such as not being able to apply transformations or
transparency and not being able to use the output as a visual brush or
texture."
So I uncheck the "AllowsTransparency" in an application that i’m doing and the problem is solve…. but, another problem came…. the window now display borders….
This page is where I found it… and at the bottom of the page is a link to a solution (convert html yo wpf) but I ain’t test it yet… if theres anothe solution… welcome.
http://learnwpf.com/Posts/Post.aspx?postId=7d0f2ec0-6a1e-46ca-88ce-7e75f8457d63
If I want to display a html file with the Frame control inside the GlassWindow this does not work.
Try enter this as the content of a GlassWindow: <Frame Source="File.html" />
Now the html file is loaded but is not visible – do a select-all inside the where the html should show up and then paste it to notepad, the content is pasted! If I use a standard Window control the file is visible.
Any idea why?
Great windows! But I have 1 minor problem. When I use the vista window in my own code and I open an instance of the window all works great! But then I close the window and try to re-open the window (another instance) and I get the following error:
Cannot set Visibility or call Show or ShowDialog after window has closed.
Is this a bug in the GlassWindow code or should I be doing something in my code to handle the closing of the glass window? Thanks in advance, and great blog!
Hey Pavan, thanks for this control.
Josef Goldberg has just blogged today about a hotfix available for download to fix the slow rendering on Vista. I was getting pretty choppy performance pre hotfix, and it’s very smooth afterwards.
http://blogs.msdn.com/jgoldb/archive/2007/10/10/performance-improvements-in-wpf-in-net-3-5-3-0-sp1.aspx
Hope that helps.
Joe
And of course I gave the wrong link!
http://blogs.msdn.com/jgoldb/archive/2008/01/23/vista-layered-windows-performance-hotfix-now-available-on-microsoft-download-center.aspx
Joe
Thanks Joe,
I knew about it through a post from the WPF SDK blog. I guess now we can go crazy with this control !
Great work – I’m wondering though, is there a way to get the full glow that you get when moving your mouse over the control buttons (min, max, close) – the “outer glow” affect that spreads off the window onto the desktop beneath? I don’t want the windows I design to be less attractive than the default Vista windows in that way. The spreading-glow affect is pretty popular with my users.
btw, thank you for sharing the fruit of your expertise.
JH
You can sure do that. Its just a little tweak in the control template. The trick is to leave some room for the glow at the top by making the container of the buttons transparent. The glow itself could be a bitmap filter.
[...] ( Part 1, Part 2 [...]
Great job! Very clean and well thought out, impressive. While playing around I found a minor issue that you might want to know about; if you set the window “SizeToContent” property it will maximize the window instead. Cheers!
Thanks Anthony…GlassWindow is now part of FluidKit: http://www.codeplex.com/fluidkit. I have added a bug report for your finding …