<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>

<!-- Example 16-9. Enter and exit actions -->

<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>

<!-- End of Example 16-9. -->

</Page.Resources>

<StackPanel>
  <TextBox Style="{StaticResource widthOnFocus}" Width="200" />
  <TextBox Style="{StaticResource widthOnFocus}" Width="200" />
</StackPanel>


</Page>
