1

我寫了簡單的模板中的XAML按鈕S(銀光4)
So when I try use "ControlTemplate.Triggers", I found that is impossible in silver-light, and we must use Visual-State in Silver-Light
所以我寫了第一個控件模板與Visual國家,但它不能正常工作。(這裏是代碼)SilverLight中的視覺狀態? (我們如何使用)

<Style x:Key="NextButtonStyle" TargetType="Button"> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate> 
        <Grid x:Name="MainGrid"> 
         <Border x:Name="MainBorder" 
           BorderThickness="2" 
           BorderBrush="#FFC0C0C0" 
           Background="Bisque" 
           CornerRadius="4 4 4 4" > 
          <TextBlock x:Name="lbl" 
             VerticalAlignment="Center" 
             HorizontalAlignment="Center" 
             Text=">" 
             Foreground="#FFC0C0C0" 
             FontWeight="Bold" 
             FontFamily="TimesNewRoman" 
             FontSize="15"/> 
         </Border> 
         <vsm:VisualStateManager.VisualStateGroups> 
          <vsm:VisualStateGroup x:Name="CommonStates"> 
           <vsm:VisualState x:Name="MouseOver"> 
            <Storyboard> 
             <ColorAnimationUsingKeyFrames AutoReverse="False" Duration="00:00:00.2" 
                     Storyboard.TargetName="MainBorder" 
                     Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color}"> 
              <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF606060"/> 
             </ColorAnimationUsingKeyFrames> 
             <ColorAnimationUsingKeyFrames AutoReverse="False" Duration="00:00:00.2" 
                     Storyboard.TargetName="lbl" 
                     Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color}"> 
              <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF606060"/> 
             </ColorAnimationUsingKeyFrames> 
            </Storyboard> 
           </vsm:VisualState> 

          </vsm:VisualStateGroup> 
         </vsm:VisualStateManager.VisualStateGroups> 
        </Grid> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 

當我使用這種風格,並在此邊框上移動此邊框時,border和textbloc都變爲不可見。所以
1)我該怎麼辦?
2)是否有任何良好的例子視覺狀態

+0

我沒有明白你的意思,你是否在創建的templte/style中遇到了一些問題? – Malcolm 2010-06-28 06:37:53

+0

現在我簡單地用Blend 3創建visusal-state。爲此,你應該知道如何使用Blend。所以這是學習混合3和視覺狀態的好例子:http://electricbeach.org/?p=350 – Rev 2010-07-06 11:16:30

回答

0

由於兩個簡單的錯誤,你的風格不起作用,否則一切都是正確的。

1)Storyboard.TargetProperty = 「(Border.BorderBrush)(SolidColorBrush.Color }

這將是: Storyboard.TargetProperty =」(Border.BorderBrush)。(SolidColorBrush.Color )

2)同樣適用於正文塊: Storyboard.TargetProperty = 「(TextBlock.Foreground)(SolidColorBrush.Color }

這將是: Storyboard.TargetProperty =」(TextBlock.Foregrou nd)。(SolidColorBrush.Color )

+0

這麼愚蠢的錯誤! 「感謝您的大力幫助」是否有關於視覺狀態的好文章 – Rev 2010-06-28 10:20:26

+0

據我所知,沒有提供這麼好的文章。但我會告訴你我的看法,當我剛剛進入視覺狀態時,我做了什麼。只需安裝表達式混合 - 表達式混合自動爲您生成所有的vsm。然後,只需編輯vsm,使用其屬性進行遊戲,即可完成狀態轉移。 http://expression.microsoft.com/en-us/cc197141.aspx – Malcolm 2010-06-28 10:54:06

+1

非常好的提示'表達混合'。我有,但我不知道如何處理(專門用於創建動畫,效果和視覺狀態)如何訪問有關Blend 3的良好指南。 – Rev 2010-06-29 03:25:22

相關問題