2011-10-11 111 views
0

我爲我的項目創建了一個按鈕樣式。當用戶將光標移動到其上時,我希望按鈕閃爍。我這樣做與此代碼:xaml按鈕焦點與按鈕鼠標

<Trigger Property="IsMouseOver" Value="True"> 
    <Trigger.EnterActions> 
     <BeginStoryboard> 
      <Storyboard> 
       <ColorAnimation Storyboard.TargetProperty="Background.Color" Duration="0:0:0.2" From="#808000" To="#ffaec9" RepeatBehavior="Forever" AutoReverse="True"/> 
      </Storyboard> 
     </BeginStoryboard> 
    </Trigger.EnterActions> 
</Trigger> 

我也想然後用戶焦點按鈕它也閃光。但是,如果我爲IsFocused屬性創建類似的代碼將無法正常工作。我可以在標記觸發器的屬性屬性中使用屬性串聯嗎?我可以創建觸發器序列(trigger1工作,如果它在triпger2之前工作,並且如果工作trigger3不會工作)?

+1

爲什麼你的arent考慮多觸發器或Visual國家經理的工作? –

回答

1

使用這種狀態下,它會在你的WPF按鈕

<VisualState x:Name="MouseOver"> 
     <Storyboard> 
     <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)" Storyboard.TargetName="Background" d:IsOptimized="True"/> 
     </Storyboard> 
</VisualState>