WPF – Tip – AllowsTransparency + Popup = brain cast exception


Hi there!

Today I would like to share with you a tip that I encountered on my current project in .Net 3.5.

Problem
I was seeing why my WebBrowser component didn't want to work in a custom popup. And I didn't know why, I had the same effect on my ComboBox component... I mean that the combo box stopped showing its items ... After spent a lot of time with debbuger tools (snoop, vs output ans so on) I was tired and the last thing that I didn't see was resource dictionary file.

Solution
And it was exactly the problem! Indeed, the popup style enabled the AllowsTransparency property (AllowsTransparency=true) I've reproduced the problem with a webBrowser in a popup control as you can see:

And if you set AllowsTransparency = true, the popup will not show it in the WebBrowser component...
So, if you want to see your popup correctly in your project, you have to isolate your code (WebBrowser, ComboBox) that you want to display inside your popup and set AllowsTransparency = false on it.

Hope this help !

PS: Thanks to Arnaud Auroux for having investigated this problem with me 😀

Skip to main content