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

相关问题