Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Why one trigger works but the other doesn't?

$
0
0

... or actually the trigger seems to work but the property setting seems not to.

I'm a newbie in WPF and tried two examples.

Any idea what's wrong here?

The square works as supposed (turns red when mouse cursor is over it) but

the button doesn't. The colour doesn't turn to orange and text doesn't change.

Only font gets bigger when mouse cursor is over the button.

The XAML:

<Window x:Class="WpfKoe3.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525"><Window.Resources><Style TargetType="Button" x:Key="Buttonstyle" ><Setter Property="Background" Value="LightBlue" /><Style.Triggers><Trigger Property="IsMouseOver" Value="true"><Setter Property="Background" Value="Orange" /><Setter Property="Content" Value="Yahoo" /><Setter Property="FontSize" Value="20" /></Trigger></Style.Triggers></Style><Style x:Key="styleWithTrigger" TargetType="Rectangle"><Setter Property="Fill" Value="LightGreen" /><Style.Triggers><Trigger Property="IsMouseOver" Value="True"><Setter Property="Fill" Value="Red" /></Trigger></Style.Triggers></Style></Window.Resources><Grid><Button Content="Button" HorizontalAlignment="Left" Margin="67,96,0,0" VerticalAlignment="Top" Width="75" Height="75" Style="{StaticResource Buttonstyle}"></Button><Rectangle Style="{StaticResource styleWithTrigger}" Margin="177,96,216,149"></Rectangle></Grid></Window>

I'm using Visual Studio 2012 Professional.




Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>