反转 wpf 视觉状态转换
我有一个自定义 WPF 控件,具有两种视觉状态 - 已启用和已启用。残疾人。禁用状态有一个简单的过渡动画,用于禁用控件,然后在短暂延迟后将其淡出。然后我有相反的动画,它在控件中淡出,并在转换到启用状态时重新启用它(没有延迟)。
我遇到的问题是,如果我在它开始淡出之前将状态从“禁用”更改为“启用”,那么我仍然需要等待淡入动画,然后才能重新启用控件,实际上,它可以直接启用控制,并避免淡入部分。
解决这个问题的正确方法是什么?我需要根据禁用转换故事板中的当前时间(减去初始延迟)设置“启用”转换故事板的起点。
我想,另一种方法是有两种状态,一种表示“禁用”,一种表示“褪色”。一旦禁用状态动画完成,如果可以从故事板更改视觉状态,我可以在禁用故事板完成后进入褪色状态。然后我可以定义从“禁用”到“启用”以及“淡入淡出”到“启用”的不同转换。
这可能吗?
谢谢!
I have a custom WPF control with two visual states - Enabled & Disabled. The disabled state has a simple transition animation that disables the control, then fades it out after a short delay. Then I have the reverse of the animation, where it fades in the control, and re-enables it (with no delay), when transitioning to the Enabled state.
The problem I have is if I change the state from Disabled and then back to enabled again before it had started to fade out, then I still have to wait through the fade-in animation before it re-enables the control, where in actuality, it could just enable the control straight away, and avoid the fade-in part.
What's the right way to go about fixing this? I sort of need to set the start point of the "Enabled" transition storyboard based on the current time in the Disabled transition storyboard (minus the initial delay).
Another way, I guess, is to have two states one saying Disabled and one saying faded. Once the disabled state animation completes, if it was possible to change visual states from a storyboard, I could enter the Faded state after the disabled storyboard had completed. Then I can have different transitions defined from Disabled to Enabled and Faded to Enabled.
Is this possible?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于启用和禁用动画,我猜您是否正确地定义了 From 和 To 值?这可以解释您所描述的行为。
如果您省略 From 值,仅指定 To 值,则指定的属性将从当时的任何值(例如,半褪色)动画到您指定的任何值。这不是将值弹出到您指定的 From 值,然后动画到 To 值。
for the enabling and disabling Animations, do i guess correctly that you have both the From and To values defined? that would account for the behavior that you describe.
if you leave out the From value, specifying only the To value, the specified property will animate from whatever its value is at the time (so, for instance, half faded) to whatever you specify. this is instead of popping the value to the From value you specify and then animating to the To value.