WPF中是否有MergedGradientBrush? [英] Is there a MergedGradientBrush in wpf?

查看:75
本文介绍了WPF中是否有MergedGradientBrush?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有两把刷子.
一种是从深到浅的线性渐变画笔
一个是从黑暗到光明的放射状刷子.

Suppose I had two brushes.
One that was a linear gradient brush that was from Dark to light
One was a radial brush that went from Dark to light.

如何合并画笔,以便在应用它们时可以一次应用两个.
EG检查此:
1) http://www.codeproject.com/KB/vista/WindowsVistaRenderer/VistaRenderer4.gif
2) http://www.codeproject.com/KB/vista/WindowsVistaRenderer/VistaRenderer5.gif

How could I merge the brushes so that when I apply them, I can apply both at once.
EG Check this:
1) http://www.codeproject.com/KB/vista/WindowsVistaRenderer/VistaRenderer4.gif
2) http://www.codeproject.com/KB/vista/WindowsVistaRenderer/VistaRenderer5.gif

如何(在WPF/XAML中)如何将两者合并为一个渐变,然后再进行引用? (这是Menendez先生来自Codeproject的图片)

How could I (In WPF/XAML) merge both into one gradient and then refer to that? (This is Mr. Menendez's Images from Codeproject)

推荐答案

简短的回答,无法将两个不同的渐变笔刷合并"为一个.但是,有一些变通办法可以为您完成工作.例如,您可以创建两个重叠的Border元素(使用Grid),一个元素使用线性笔刷,另一个元素使用渐变笔刷.然后,您可以将画笔中每种颜色的alpha分量设置为50%透明度.以这种方式,笔刷会被一个接一个地渲染,但是两者表现得都一样好.

Short answer, there is no way to "merge" two different gradient brushes into one. However, there are workarounds that will get the job done for you. You could, for example, create two overlaid Border elements (using a Grid), one with the linear brush and the other with the gradient brush. You could then set the alpha component of each of the colors in the brushes to 50% transparency. In that manner, the brushes would be rendered one on top of the other, but both would show up equally well.

这篇关于WPF中是否有MergedGradientBrush?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆