2010-11-25 9 views
0

グリッドに2つのテキストボックスがあるウィンドウがあります。グリッドには、いずれかのテキストボックスのテキストが変更されたときにアニメーションを起動するトリガが1つ含まれています。問題。私は、アニメーションの影響を受けるように更新されたテキストボックスが欲しいです、私はStoryBoard.TargetNameを動作させるためにテキストボックスの名前に設定しなければなりません。ここでWPF、2つのテキストボックス、1つのトリガー、1つのアニメーション?

は抜粋です:

<Window x:Class="WpfApp.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="MainWindow" Height="229" Width="413" 
<Grid Width="395" Height="185"> 
    <Grid.Triggers> 
     <EventTrigger RoutedEvent="TextBox.TextChanged"> 
      <BeginStoryboard> 
       <Storyboard> 
        <ColorAnimation AutoReverse="False" Duration="0:0:1" From="Orange" To="White" 
        Storyboard.TargetName="txtBox1" AccelerationRatio="1" 
        Storyboard.TargetProperty="(TextBox.Background).(SolidColorBrush.Color)" 
        FillBehavior="HoldEnd"> 
        </ColorAnimation> 
       </Storyboard> 
      </BeginStoryboard> 
     </EventTrigger> 
    </Grid.Triggers> 
    <TextBox x:Name="txtBox1" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Left" Margin="8,128,0,33" Width="378" FontFamily="Consolas" Text="{Binding Path=Output}" Height="23" /> 
    <TextBox Height="23" HorizontalAlignment="Left" Margin="8,150,0,0" Name="textBox1" VerticalAlignment="Top" Width="378" /> 
</Grid> 

答えて

0

は、各TextBox

+0

ため、そのスタイルを使用して、私はそれを試してみましたが、私は新たな活力とそれを攻撃してきたし、それが機能するようになりました、リソース領域に(TextBoxタイプ用)という名前のスタイルでトリガをかける:)ここにあります私が追加したリソース。 – Ian

0

も ​​"IsFocused" をチェックMultiTriggerを作成していただきありがとうございます。

関連する問題