wpf - 为 Mah:Tile 添加颜色动画
问题描述
我正在使用MahApps.Metro,并且正在使用加载有命名空间“MahCtrl”( xmlns:MahCtrl="http://metro.mahapps.com/winfx/xaml/controls
) 的 Tile 元素。我想在和上申请ColorAnimation
Tile 。MouseEnter
MouseLeave
这是我目前正在处理的 xaml 片段。
<UserControl xmlns:MahCtrl="http://metro.mahapps.com/winfx/xaml/controls">
<MahCtrl:Tile Cursor="Hand" Background="Transparent" Height="200" Width="210"HorizontalContentAlignment="Center">
<MahCtrl:Tile.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation
Duration="0:0:0.200"
Storyboard.TargetProperty="(MahCtrl:Tile.Background).Color"
To="#fffccc" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="MouseLeave">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation
Duration="0:0:0.250"
Storyboard.TargetProperty="(MahCtrl:Tile.Background).Color"
To="#ffffff" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</MahCtrl:Tile.Triggers>
</MahCtrl:Tile>
</UserControl>
在调试部分中,当我在 Tile 中输入鼠标时发生以下异常
System.InvalidOperationException:“无法解析属性路径“(0).Color”中的所有属性引用。验证适用的对象是否支持这些属性。
我已经尝试过使用(Background).Color
和许多其他组合,StoryBoard.TargetProperty
但是当MahCtrl:Tile
元素用堆栈面板包装并将事件触发器MouseEnter
和MouseLeave
带有目标(StackPanel.Background).Color
的触发器应用于 StackPanel 时,此方法有效。如何定位背景属性MahCtrl:Tile
如果有人可以参考有关此主题的文档,那将是一个很大的帮助
非常感谢,
解决方案
推荐阅读
- python - 根据值移动数据 (CSV) - Python / Excel
- r - 如何在 R 中生成 LaTeX 以报告带有 APA 格式错误术语的 ANOVA?
- java - 使用 DOM 解析和处理 3GB 的 xml 文件时出现堆内存问题
- javascript - map.array 中的 if 语句与反应
- angular - 如何在 ng 中创建动态表单以将数据发布到数据库?
- for-loop - 有没有办法在 C++17 中创建一个范围内的 for 循环而无需内存费用?
- c - 如何在传入消息中添加时间字段?
- swift - Swift Ui 中 ForEach 中的限制元素
- php - Laravel - 设置 published_at 属性
- excel - Range.MergeCells 属性未更新