2016-12-09 1 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> 

주 대상 속성은 Background보다는 Background.Color입니다.

+0

이 대답이 수용 가능한 경우 ** 수락 **합니다. –