2012-03-14 57 views
0

後,所以我試圖讓一個按鈕,將改變形象,當鼠標移到/ OUT /下/上....觸發不火EventTrigger解僱

並想出了以下內容:

<Image> 
    <Image.Style> 
     <Style TargetType="{x:Type Image}"> 
      <Style.Triggers> 
       <Trigger Property="IsEnabled" Value="True"> 
        <Setter Property="Source" Value="/MyWPF;component/Resources/MediaPlayer/Play-Normal-icon.png"/> 
       </Trigger> 
       <Trigger Property="IsMouseOver" Value="True"> 
        <Setter Property="Source" Value="/MyWPF;component/Resources/MediaPlayer/Play-Pressed-icon.png"/> 
       </Trigger> 
       <Trigger Property="IsMouseOver" Value="False"> 
        <Setter Property="Source" Value="/MyWPF;component/Resources/MediaPlayer/Play-Normal-icon.png"/> 
       </Trigger> 
       <Trigger Property="IsEnabled" Value="False"> 
        <Setter Property="Source" Value="/MyWPF;component/Resources/MediaPlayer/Play-Disabled-icon.png"/> 
       </Trigger> 
       <EventTrigger RoutedEvent="MouseDown"> 
        <EventTrigger.Actions> 
         <BeginStoryboard> 
          <Storyboard> 
           <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="Source" Duration="00:00:00.5"> 
            <DiscreteObjectKeyFrame KeyTime="00:00:00"> 
             <DiscreteObjectKeyFrame.Value> 
              <BitmapImage UriSource="/MyWPF;component/Resources/MediaPlayer/Play-Hot-icon.png"/> 
             </DiscreteObjectKeyFrame.Value> 
            </DiscreteObjectKeyFrame> 
           </ObjectAnimationUsingKeyFrames> 
          </Storyboard> 
         </BeginStoryboard> 
        </EventTrigger.Actions> 
       </EventTrigger> 
       <EventTrigger RoutedEvent="MouseUp"> 
        <EventTrigger.Actions> 
         <BeginStoryboard> 
          <Storyboard> 
           <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="Source" Duration="00:00:00.5"> 
            <DiscreteObjectKeyFrame KeyTime="00:00:00"> 
             <DiscreteObjectKeyFrame.Value> 
              <BitmapImage UriSource="/MyWPF;component/Resources/MediaPlayer/Play-Normal-icon.png"/> 
             </DiscreteObjectKeyFrame.Value> 
            </DiscreteObjectKeyFrame> 
           </ObjectAnimationUsingKeyFrames> 
          </Storyboard> 
         </BeginStoryboard> 
        </EventTrigger.Actions> 
       </EventTrigger> 
      </Style.Triggers> 
     </Style> 
    </Image.Style> 
</Image> 

鼠標上/下工作正常。

但是,一旦我做了一個鼠標點擊(向下),EventTriggers發射,我可以看到圖像改變。

釋放鼠標點擊(上),EventTriggers再次發射,我可以看到圖像改變回假設的方式。

現在我將鼠標懸停在圖像上。它好好嘗試改變形象了....

但是當我做鼠標下降/上升仍然是工作......

所以我居興莫名其妙的EventTrigger overrided的IsMouseOver觸發器?

EventTrigger是否會覆蓋其他觸發器?

P.S .:對於那些讀過我以前的問題的人,抱歉,我不知道問題是由於Button在數據綁定中被禁用而引起的。

回答