Mega Code Archive

 
Categories / C# / WPF
 

Trigger Property=FrameworkElement IsFocused

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"       HorizontalAlignment="Stretch" VerticalAlignment="Stretch">     <Page.Resources>         <Style x:Key="widthOnFocus">           <Style.Triggers>             <Trigger Property="FrameworkElement.IsFocused" Value="True">               <Trigger.EnterActions>                 <BeginStoryboard Name="changeWidth">                   <Storyboard>                     <DoubleAnimation Storyboard.TargetProperty="(FrameworkElement.Width)" To="300" Duration="0:0:5" />                   </Storyboard>                 </BeginStoryboard>               </Trigger.EnterActions>               <Trigger.ExitActions>                 <RemoveStoryboard BeginStoryboardName="changeWidth" />               </Trigger.ExitActions>             </Trigger>           </Style.Triggers>         </Style>     </Page.Resources>          <StackPanel>       <TextBox Style="{StaticResource widthOnFocus}" Width="200" />     </StackPanel> </Page>