1
控件的内容是否可以对其父项的视觉状态变化做出反应?对内容状态变化的反应(Windows Phone)
在下面的例子中,当父控件处于活动状态时,我希望textblock的前景变为红色。但是这个代码不工作:
<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,它仍然可以修改TextBlock的 – bdimag 2014-10-30 21:23:55
@bdimag第一部分是真实的,但第二个不是,因为'VisualStateGroups'在那里将是无效的。 VisualStateGroups只能在ControlTemplate或UserControl的根元素下定义。 – McGarnagle 2014-10-31 00:47:53