I can't get the following to work. The goal is to change the ZIndex of the usercontrol when the mouse is over its content.
Using a simple property like "Background" instead of ZIndex does not work either. The compiler complains about "Value 'Grid.IsMouseOver' cannot be assigned to property 'Property'. Object reference not set to an instance of an object." (After compiling and starting the project).
Can someone please provide a working example of a trigger which changes some properties of a different control?
<UserControl x:Class="ImageToolWPF.Controls.sample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300">
<UserControl.Triggers>
<Trigger SourceName="viewPort" Property="Grid.IsMouseOver" Value="True">
<Setter TargetName="me" Property="UserControl.Panel.ZIndex" Value="2" />
</Trigger>
</UserControl.Triggers>
<Border Name="border" CornerRadius="3,3,3,3" BorderThickness="3" BorderBrush="Green">
<Grid Name="viewPort">
<Label Name="labelTop" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="16" Background="#a0ffffff" Padding="4"/>
</Grid>
</Border>
</UserControl>