Mega Code Archive

 
Categories / VB.Net Tutorial / WPF
 

Using a Trigger to modify the appearance of any Control

<Page     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">     <Page.Resources>         <Style x:Key="Triggers">             <Style.Triggers>                 <Trigger Property="Control.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 Triggers}" Content="My Button" />         <TextBox Style="{StaticResource Triggers}">My Text</TextBox>     </StackPanel> </Page>