2016-12-09 21 views
0

私はXAML領域で初心者ですが、VSMについて学びたいだけです。私がStoryBoardに何かを加えると、いつも同じエラーが警告されました。アニメーションの境界線の背景色を変更します。

指定されたオブジェクトのTargetProperty Background.Colorを解決できません。

<phone:PhoneApplicationPage.Resources> 
    <ControlTemplate x:Key="ButtonControlTemplate1" TargetType="Button"> 
     <Border 
      BorderThickness="{TemplateBinding BorderThickness}" 
      Height="{TemplateBinding Height}" 
      Width="{TemplateBinding Width}" 
      Margin="{TemplateBinding Margin}" 
      Padding="{TemplateBinding Padding}" 
      Background="{TemplateBinding Background}" 
      BorderBrush="{TemplateBinding BorderBrush}" 
      Name="btnBorder"> 
      <VisualStateManager.VisualStateGroups> 
       <VisualStateGroup x:Name="CommonStates"> 
        <VisualState x:Name="Normal"/> 
        <VisualState x:Name="MouseOver"> 
         <Storyboard> 
          <ColorAnimation Duration="0" 
              To="Blue" 
              Storyboard.TargetName="btnBorder" 
              Storyboard.TargetProperty="Background.Color" 
              /> 
         </Storyboard> 
        </VisualState> 
        <VisualState x:Name="Pressed"/> 
        <VisualState x:Name="Disabled"/> 
       </VisualStateGroup> 
      </VisualStateManager.VisualStateGroups> 
      <ContentPresenter 
       HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" > 
      </ContentPresenter> 
     </Border> 
    </ControlTemplate> 
</phone:PhoneApplicationPage.Resources> 

<Button 
      x:Name="btnSubmit" 
      Grid.Row="3" 
      Grid.Column="0" 
      Grid.ColumnSpan="2" 
      Content="Login" 
      IsEnabled="False" 
      Click="btnSubmit_Click" 
      Margin="0" 
      BorderThickness="2" 
      BorderBrush="White" 
      Background="Aqua" 
      Padding="15" 
      Template="{StaticResource ButtonControlTemplate1}" 
      /> 

なぜ、どのようにそれを修正しました!

答えて

2

あなたの視覚状態はMouseOverではなくPointerOverである必要があります。

でも、ColorAnimationは私のために何もしません。これは、しかし、行います

<VisualState x:Name="PointerOver"> 
    <Storyboard> 
     <ObjectAnimationUsingKeyFrames 
      Storyboard.TargetName="btnBorder" 
      Storyboard.TargetProperty="Background"> 
      <DiscreteObjectKeyFrame KeyTime="0" Value="Blue" /> 
     </ObjectAnimationUsingKeyFrames> 
    </Storyboard> 
</VisualState> 

注意targetプロパティはBackgroundいうよりBackground.Colorです。

+0

この回答が受け入れられる場合は、**受け入れるように**してください。 –

関連する問題