如何在wpf中为同一图像设置不同的不透明度? [英] How to set different Opacity to same image in wpf?
本文介绍了如何在wpf中为同一图像设置不同的不透明度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要为同一个图像设置不同的不透明度。例如:我左边有一个图像,不透明度应该是1,然后从图像的左边到右边减少不透明度,右边它应该是零。
I need to set different opacity for same image.For ex: I have one image so to left of it ,Opacity should be one and then decreasing Opacity from left to right of image,by right it should be Zero.
推荐答案
OpacityMask
应该可以解决这个问题:
AnOpacityMask
should do the trick:
<Image Source="source-image.jpg">
<Image.OpacityMask>
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5" >
<GradientStop Offset="0.0" Color="#00000000" />
<GradientStop Offset="1.0" Color="#FF000000" />
</LinearGradientBrush>
</Image.OpacityMask>
</Image>
http://msdn.microsoft.com/en-us /library/ms743320%28v=vs.110%29.aspx [ ^ ]
这篇关于如何在wpf中为同一图像设置不同的不透明度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文