WPF / Windows 7:禁用默认进度栏发光动画
快速 WPF 问题 - 在 WPF 中的 Win 7(我假设是 Vista)上,默认进度栏会显示一个漂亮的小发光“嗖嗖”动画。
我在一个屏幕上显示了大约 48 件事情的进度,所有这些事情都在你身上呼啸而过,这有点让人不知所措——你能只禁用这些动画而不影响应用程序中其他默认动画吗?
Quick WPF question - on Win 7 (and I assume Vista) in WPF, the default progress bar does a nice little glowing "whoosh"-y animation.
I'm showing progress of about 48 things on one screen, and it's a tad overwhelming to have all of these things whooshing on you - can you disable just these animations without affecting the rest of the default animations in the application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
罗伯特的回答很有力。
这是一个 hack(因为它依赖于发光元素的内部名称,这是一个实现细节,可能会在后续版本中更改):
如果进度条的实现方式发生变化,则此 hack 可能会停止工作。
另一方面,完全替换 XAML 和样式的解决方案可能会锁定并修复颜色、边框等,并禁用将来可能添加到较新版本的 ProgressBar 中的行为...
Robert's answer is robust.
Here is a hack (because it relies on the internal name of the element that does the glow, which is an implementation detail and may change in a subsequent version):
If how a progress bar is implemented changes, this hack may stop working.
On the other hand, a solution that completely replaces the XAML and styles may lock-in and fix colours, borders etc. and disable behaviour that might be added to a newer version of the ProgressBar in the future...
简单的、非动画的进度条可以写成带有两个填充矩形的网格:
例如,左边的填充为绿色,右边的填充为灰色。
网格将有两个列定义。
改变两者的宽度就会产生进度变化的效果。
The simple, non-animated progress bar can be written as a Grid with two filled rectangles:
the left one would be filled, say, with green color, the right one with gray.
The Grid would have two column definitions.
Changing the width of the two will make an effect of change of the progress.
我同意马修的评论,但无论如何,您的答案是应用没有动画的自定义样式。这是原始样式(通过反射器),您可以删除/调整/任何内容:
以及转换器类:
I'd agree with Matthew's comment, but anyway, your answer is to apply a custom style without the animation. Here's the original style (via reflector), you can remove/tweak/whatever:
And the converter class:
您也可以在Win7中一起禁用此效果。
右键单击桌面上的“我的电脑”图标,然后选择“属性”(或按 Windows 键 + 暂停/中断键),单击左侧窗格中的“高级系统设置”链接(您也可以通过在“运行”或“开始”菜单中键入 sysdm.cpl 来打开它搜索框并按 Enter)。现在单击“性能”部分中的“设置”按钮:
取消选中“在窗口内对控件和元素进行动画处理”,它应该是第一个选择。
You can also disable this effect in Win7 all together.
Right-click on My Computer icon on Desktop and select Properties (or press Windows Key + Pause/Break key), click on Advanced system settings link in left side pane (You can also open it by typing sysdm.cpl in RUN or start menu search box and press Enter). Now click on Settings button in Performance section:
Uncheck "Animate controls and elements inside windows", it should be the first selection.
不是我的领域,但这个答案可能也相关:禁用进度Vista Aero 上的栏动画
Not my area, but this answer might be relevant too: Disabling progress bar animation on Vista Aero
创建您正在使用的应用程序的快捷方式,右键单击该快捷方式并选择属性。
现在,在兼容性选项卡中单击“禁用视觉主题”复选框。
Create a shortcut to the application you are using, right click the shortcut and choose properties.
Now in the compatibility tab click the "disable visual themes" checkbox.