Is there a MergedGradientBrush in wpf?

依然范特西╮ 提交于 2020-01-06 03:18:07

问题


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.

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

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


回答1:


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.



来源:https://stackoverflow.com/questions/2925172/is-there-a-mergedgradientbrush-in-wpf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!