This blog is where I post about my consulting work with Microsoft Technologies, and other random tidbits that don't fit in my Photo Blog or my Iraq Blog.

Wednesday, February 25, 2009

Why is my WPF Popup black and how do I get it positioned properly?

A quick WPF tip:

Problem: I was trying to create a cool OS X style semi-transparent round cornered popup but no combination of setting Background=Transparent or Opacity<1 would give me anything but a big square cornered black box in the wrong part or the screen.

Solution: You need to set the AllowsTransparency property on the Popup to True, and set the PlacementTarget and Placement properties to control the position the Popup opens in.

<Popup x:Name="RecipeSourcePopup"

               PlacementTarget="{Binding ElementName=MainStackPanel}"

               Placement="Center" AllowsTransparency="True"

               HorizontalAlignment="Center" VerticalAlignment="Center" >


Unknown said...

make allowtranpeancy=true

Unknown said...

make allow tranparency of the popup =true