0
这里是我的标记为什么我的可视状态管理器不能用于指针转换?
<Grid Height="50" x:Name="TextGrid">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="TestGrid" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="Green"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="TestGrid" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource AppBarItemPointerOverBackgroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.Transitions>
<TransitionCollection>
<EntranceThemeTransition></EntranceThemeTransition>
</TransitionCollection>
</Grid.Transitions>
<Grid x:Name="TestGrid" Background="SeaShell">
<TextBlock Text="test" x:Name="testTextBlock" VerticalAlignment="Center" Foreground="OrangeRed" FontFamily="Calibri" FontSize="20" FontWeight="Light"></TextBlock>
</Grid>
我想不通为什么指针悬停效果不工作。
a。)我不认为WinRT TextBlock具有Background属性,这将需要快速模板编辑来添加一种方法来支持它。 b。)您将需要DoubleAnimation中的ColorAnimationUsingKeyFrames而不是ObjectAnimation。午餐后可以稍后提供示例;) –
感谢您的反馈意见。我更新它并将其嵌套在网格中。我知道我在这里错过了一些基本的东西。 – Smeegs
看起来我不得不让我等一会儿再提供一个例子。尽管我可能会建议一条相对简单的路线来完成你的目标。只需要窃取HyperlinkButton模板,删除除PointerOver之外的所有VisualState并根据需要进行编辑。因为你试图使用的动画类型是针对模板内容而不是依赖关系的,所以你的状态会起作用(因为我假设你已经从模板中复制/粘贴了这些部分)。否则,我应该在几个小时内腾出更多的时间。 –