I have a Stackpanel with a Image in it. The Image is partly transperent. So i want the Background to be Red, when the mouse is not over (which works). But wen the mouse is over it should turn into green. But it doesn't work. Can you please help me out.
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:shell="clr-namespace:System.Windows.Shell;assembly=PresentationFramework"> <Style x:Key="PhoenixWindowStyle" TargetType="{x:Type Window}"> <Setter Property="shell:WindowChrome.WindowChrome"> <Setter.Value> <shell:WindowChrome GlassFrameThickness="0" ResizeBorderThickness="1" CaptionHeight="32" CornerRadius="0"/> </Setter.Value> </Setter> <Setter Property="Background" Value="{DynamicResource DefaultBackgroundBrush}"/> <Setter Property="MinWidth" Value="100"/> <Setter Property="MinHeight" Value="100"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Window}"> <Grid Background="{DynamicResource BorderBrush}"> <Grid.ColumnDefinitions> <ColumnDefinition Width="1"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="1"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="32"/> <RowDefinition Height="*"/> <RowDefinition Height="1"/> </Grid.RowDefinitions> <DockPanel Grid.Column="1" Grid.Row="0"> <TextBlock DockPanel.Dock="Left" Margin="0, 2, 0, 2" Padding="0"> <Image Width="24" Height="24" Margin="2" Source="{TemplateBinding Icon}" SnapsToDevicePixels="True" RenderOptions.EdgeMode="Aliased" /> <Run BaselineAlignment="Center" Text="{TemplateBinding Title}" Foreground="{DynamicResource DefaultBackgroundBrush}"/> </TextBlock> <TextBlock DockPanel.Dock="Right" HorizontalAlignment="Right"> <!--This it the part I showed before --> <StackPanel Width="38" Height="32"> <StackPanel.Style> <Style TargetType="StackPanel"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="Green"/> </Trigger> <Trigger Property="IsMouseOver" Value="False"> <Setter Property="Background" Value="Red"/> </Trigger> </Style.Triggers> </Style> </StackPanel.Style> <Image Width="38" Height="32" Margin="0" Source="../Images/FrameControlIcons/38x32/close.png"/> </StackPanel> <!--/////////////////////--> </TextBlock> </DockPanel> <DockPanel Grid.Column="1" Grid.Row="1" > <ContentPresenter /> </DockPanel> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary>
BackgroundtoGreenwhenIsMouseOveris true and red when false