1
컨트롤 내용이 부모의 시각적 상태 변화에 반응 할 수 있습니까?내용의 상태 변화에 대한 반응 (Windows Phone)
다음 예제에서는 부모 컨트롤이 활성화되어있을 때 텍스트 블록의 전경을 빨간색으로 변경하고 싶습니다. 하지만이 코드는 작동하지 않습니다
<local:ExpandKeyButton x:Name="xpand" Height="30">
<TextBlock x:Name="tb">
Test
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="General">
<VisualState x:Name="Idle" />
<VisualState x:Name="Active">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="tb" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="Red" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</TextBlock>
</local:ExpandKeyButton>
스토리 보드 안쪽으로 타겟팅 할 수 있습니다 - 당신이 지역에 VisualStateGroups를 설정 한 경우 즉, : ExpandKeyButton, 그것은 여전히 첫 번째 부분이 참 @bdimag TextBlock을 – bdimag
을 수정할 수 있지만, 두 번째가 아닌, VisualStateGroups''때문에 거기에 무효가 될 것이다. VisualStateGroups는 ControlTemplate 또는 UserControl의 루트 요소에서만 정의 할 수 있습니다. – McGarnagle