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並根據需要進行編輯。因爲你試圖使用的動畫類型是針對模板內容而不是依賴關係的,所以你的狀態會起作用(因爲我假設你已經從模板中複製/粘貼了這些部分)。否則,我應該在幾個小時內騰出更多的時間。 –