In XAML, Why a Transparent background blocks this Trigger?

wpf, xaml

Solution

This is a side effect of how layered windows are handled at the Win32 level: wholly transparent pixels (i.e., with zero alpha) are not visible to hit testing, and therefore will not generate mouse events.

Since all mouse events pass through your window, your window's cursor will not be displayed. So, while your trigger may fire, it is rendered useless by the hit testing behavior. Even if you hard-code the window's `Cursor` property to `ArrowCD`, you will never see that cursor unless the mouse is over non-transparent content within the window.

Problem

This happens only when I set the background to Transparent, which is the effect that I need. Changing the background to AliceBlue for example, allows the trigger to take an effect. What could be missing here behind the scenes? ``` <Window AllowsTransparency="True" Background="Transparent"> <Window.Style> <Style> <Style.Triggers> <Trigger Property="Window.IsActive" Value="True"> <Setter Property="Window.Cursor" Value="ArrowCD" /> </Trigger> </Style.Triggers> </Style> </Window.Style> <Grid VerticalAlignment="Center" HorizontalAlignment="Center"> <TextBlock> Some Text </TextBlock> </Grid> </Window> ```

Original source