WPF : Opaque child windows on a transparent parent background

If you set a parent window’s Opacity, any child windows can only have an opacity equal to or below the parent window’s. So if you want to keep the main window background transparent but leave the child controls (such as a text box) fully opaque, it will not work as you expect. One solution (there are possibly others too) is to do the following.

Set the main window’s AllowTransparency to true and set the Background to Transparent.

<Window . . .
    AllowsTransparency="True" Background="Transparent"

Now say you main panel is a grid, put a Border control on it as follows :

<Border Opacity="0.9" . . .>
          . . .

Set the border’s background to what you originally wanted the main window’s background to be. Now you’ll find a transparent window background where your editable controls can still retain 100% opacity.

Warning : Setting AllowTransparency to true on the main window potentially results in some very bad performance issues on both XP and Vista since WPF switches to software rendering (in my experience, even with good video cards). Once that happens, animations and video can get pretty unusably slow.

C++/CLI Article : Deriving from a C# disposable class

Last week at work, I had to work on a C++/CLI class that derived from a class written in C# which implemented IDisposable. I got it wrong at first (yeah, same guy who wrote a book on the subject a couple of years ago) and my boss and I spent some time going through the generated code in Reflector before fixing it up. I came home that night and quickly put together a simple project so I could see the whole picture from a simple perspective. I thought it would benefit others to put together an article reflecting (no pun intended) the issue.