2010-09-17 43 views
2

最好不使用後端代碼?我正在尋找最乾淨的解決方案,使用2張圖像淡入淡出懸停按鈕。以下是我迄今爲止如何在Silverlight中使用2個圖像做簡單的懸停按鈕

編輯:

我得到了這部分工作..問題是,現在的鼠標移開似乎突然而鼠標懸停似乎罰款,我究竟做錯了什麼?

<VisualStateGroup x:Name="CommonStates"> 
    <VisualState x:Name="Normal" /> 
    <VisualState x:Name="MouseOver"> 
     <Storyboard> 
      <DoubleAnimation BeginTime="0:0:0" Duration="0:0:1" To="1" 
           Storyboard.TargetProperty="(UIElement.Opacity)" 
           Storyboard.TargetName="mouseOverImage" d:IsOptimized="True"/> 
      </Storyboard> 
    </VisualState> 
    <VisualState x:Name="MouseOut"> 
     <Storyboard> 
      <DoubleAnimation BeginTime="0:0:0" Duration="0:0:1" To="0" 
           Storyboard.TargetProperty="(UIElement.Opacity)" 
           Storyboard.TargetName="mouseOverImage" d:IsOptimized="True"/>           
     </Storyboard> 
    </VisualState> 
    <VisualState x:Name="Pressed"/> 
    <VisualState x:Name="Disabled"/> 
</VisualStateGroup> 
<VisualStateGroup x:Name="FocusStates"> 
    <VisualState x:Name="Focused"/> 
    <VisualState x:Name="Unfocused"/> 
</VisualStateGroup> 

回答

0

發現沒有默認的視覺狀態叫做鼠標。正常狀態將作爲鼠標或鼠標鍵。

        <Storyboard> 
             <DoubleAnimation BeginTime="0:0:0" Duration="0:0:0.5" From="0" To="1" 
                  Storyboard.TargetProperty="(UIElement.Opacity)" 
                  Storyboard.TargetName="mouseOverImage" />        
            </Storyboard> 
           </VisualState> 
           <VisualState x:Name="Normal"> 
            <Storyboard> 
             <DoubleAnimation BeginTime="0:0:0" Duration="0:0:0.5" From="1" To="0" 
                  Storyboard.TargetProperty="(UIElement.Opacity)" 
                  Storyboard.TargetName="mouseOverImage" /> 
            </Storyboard> 
相關問題