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