Today I ran into a very strange problem:
I have a popup menu that opens when I hover over the image. The popup menu is located to the right of the image.
this template popup looks like a rectangle with a small arrow pointing to the image
the menu contains elements that are clickable, so I need to be able to move the mouse from the image to the menu without closing between them, and here I am confused: if I move the mouse directly above the end of the arrow and then the menu, everything works fine. If I move the mouse over the transparent space between the image and the menu (above or below the arrow), the menu disappears.
Here is the template for the menu:
<Popup AllowsTransparency="True" Name="c_popup" Width="300" PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" Placement="Right"> <Grid Background="Transparent"> <Grid.ColumnDefinitions> <ColumnDefinition Width="10" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Path Data="M 0 10 L 10 0 10 20 Z" Stroke="#252C37" Fill="#252C37" Margin="0,18,0,0" Grid.Column="0" /> <Grid Grid.Column="1" Background="#252C37"> <TextBlock Text="{Binding Name}" Margin="20,10,0,0" FontSize="18" Foreground="White" HorizontalAlignment="Stretch" VerticalAlignment="Top" TextWrapping="WrapWithOverflow" /> </Grid> </Grid> </Popup>
you will notice that I specifically put Background = " Transparent " and not Null (I am aware of the effect of this as on hitTesting, see this question )
The funny thing is, though: if I put Background = "# 01000000", it works as expected. (And I get almost what I want, as it is an almost transparent background)
but I still would like to know what is happening there ...
I suspect this has something to do with the fact that this is a pop-up menu. I believe that WPF is doing something to remove hitTesting on any surface that is transparent in the popup menu, or when the background is zero (which is expected), or even if it is specifically set to transparency (not expected). Can anyone confirm this?