I have an application that I use with AllowsTransparency set to true to allow me to make my window have rounded corners and no windows bar on top. I recently needed to added the use of a windows form control but the control will only show if I set the AllowsTransparency back to false and that then changes the whole look of the application. Any ideas?
views:
135answers:
2Have you checked the order of the controls that you are using?
Should be the Control at the top allowing transparency Then a Grid or some other layout with a fill specified The all other controls after that
It sounds like the control you are trying to add / edit is in the wrong order and inheriting it directly from the above control in the hierarchy.
AllowsTransparency is slow and buggy, it can even make your application crush or cause other application to behave strangely (due to bugs in the graphics driver, but your users will blame you).
Look at this post to learn how to remove the title bar and have round corners without using AllowsTransparency: http://blogs.msdn.com/wpfsdk/archive/2008/09/08/custom-window-chrome-in-wpf.aspx (look for the section titles "Office 2007 without Aero – Or, you are responsible for everything").
In short, use PInvoke to call Win32 CreateRoundRectRgn and SetWindowRgn to get rounded corners.