如何在 WPF 应用程序(如 Office 2010)中对 Aero 玻璃进行渐变淡入淡出?
我正在 WPF 中编写一个应用程序,我希望应用程序的顶部从颜色淡出为 Aero 玻璃,就像 Office 2010 应用程序一样。
实际上,它会将标题栏正下方的区域从玻璃褪色为颜色。 (我认为这可能是描述它的更好方式)。
I am writing an application in WPF and I would like to have the top of the application fade from a color to Aero glass like the Office 2010 applications.
Really it will be fading the area just below the title bar from glass to a color. (I think that maybe a better way to describe it).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想出了如何让它发挥作用。 我使用本机 API 将整个窗口设置为具有航空玻璃效果,然后为窗口背景创建 LinearGradientBrush。 在画笔中,我使用了画笔的 Alpha 属性,并设置了停止点,使窗口顶部从白色/不透明变为白色/透明,所有这些都非常接近窗口顶部。
我更新了 Mikko Rantanen 的答案,因为我使用这篇文章添加了玻璃效果,但我手边没有代码,这是一篇很好的简单文章。
I figured out how to get it to work. I set the entire window to have the aero glass effect on it using the native API's and then a create a LinearGradientBrush for my background of the window. In the brush I used the Alpha properties of the brush and set the stops to have the top of the window go from white/opaque to white/transparent all very close to the top of the window.
I 1 up'd Mikko Rantanen's answer because I used the article to add the glass effect I didn't have the code handy and it was a good simple article.
这让我想起 Windows Explorer/Internet Explorer 在地址字段后面延续 Aero 玻璃效果的方式。 所以我猜如果有一个API可以实现这种效果,那么它将是一个本机Vista API,您需要通过P/Invoke调用,类似于扩展玻璃效果。 我相信 WPF 确实没有任何方法来控制 Vista 特定的 Aero 主题。
This reminds me of the way Windows Explorer/Internet Explorer continues Aero glass effect behind the address field. So I'd guess that if there is an API for this kind of effect, it will be a native Vista API which you need to call through P/Invoke similar to extending the glass effect. WPF doesn't really have any methods to control the Vista specific Aero theme I believe.