ウィンドウにフォーカスが当たったときに何か起こりたいです。しかし、これは動作するようには思えません。私は交換した場合一方 EnterActionsが機能するように見えるときに、スタイルトリガーのセッターが機能しないのはなぜですか?
<Window x:Class="Sample.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300" Background="Black"
Opacity="0.5">
<Grid>
</Grid>
<Window.Style>
<Style>
<Style.Triggers>
<Trigger Property="Window.IsActive" Value="true">
<Setter Property="Control.Background" Value="Blue" />
<Setter Property="Window.Title" Value="Testing" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Style>
</Window>
、{Enter,Exit}Action
のものにアニメーションでセッターが動作するように見えます。
<Window x:Class="Sample.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300" Background="Black"
Opacity="0.5">
<Grid>
</Grid>
<Window.Style>
<Style>
<Style.Triggers>
<Trigger Property="Window.IsActive" Value="true">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="Background.Color"
To="Blue" Duration="0:0:1" />
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Title">
<DiscreteObjectKeyFrame Value="Testing" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="Background.Color"
To="Black" Duration="0:0:1" />
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Title">
<DiscreteObjectKeyFrame Value="Window1" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
</Style.Triggers>
</Style>
</Window.Style>
</Window>
私は、この回避策は、私の目的のためには十分であると仮定し、私は「シンプル」な方法が動作しない理由を理解したいと思います。
P.S.私は完全に動作する構文強調を得ることができません...それはいくつかのレベルのインデント後にあきらめているようです。
いいですね。私は、アニメーションが優先レベルでより高いので動作すると思います。私はあなたのリンクを読み上げます。 – seeker