Mega Code Archive

 
Categories / VB.Net / WPF
 

Using a Trigger to modify the appearance of a single Button

<Page     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">     <Page.Resources>         <Style x:Key="ButtonTriggers" TargetType="{x:Type Button}">             <Style.Triggers>                 <Trigger Property="Button.IsMouseOver" Value="true">                     <Setter Property = "Control.Foreground" Value="Green"/>                     <Setter Property = "Control.Background" Value="Red"/>                 </Trigger>             </Style.Triggers>         </Style>     </Page.Resources>     <StackPanel>         <Button Style="{StaticResource ButtonTriggers}" Content="My Button" />     </StackPanel> </Page>