有没有办法使禁用的按钮上的图像饱和? [英] Is there a way to desaturate an Image on a Button thats disabled?

查看:78
本文介绍了有没有办法使禁用的按钮上的图像饱和?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使已禁用的按钮中的图像饱和?例如。 ICommand.CanExecute = false ?还是我需要使用单独的图像+样式/触发器

Is there a way I can desaturate images in Buttons that are disabled? eg. ICommand.CanExecute = false? or do I need to use separate images + Style/Triggers

推荐答案

我为此使用了特殊样式,这减少了禁用按钮时图像的不透明度(是的,如果按钮绑定到命令,这也可以使用)。从技术上讲,这不是去饱和,但它看起来很相似,并且可以帮助您自己得出解决方案:

I'm using a special style for this, which reduces the opacity of the image when the button gets disabled (yes, this also works if the button is bound to a command). Technically, this is not desaturation, but it looks similar and it might help you derive a solution on your own:

<Style x:Key="buttonImage">
    <Style.Triggers>
        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}, AncestorLevel=1}, Path=IsEnabled}" Value="False">
            <Setter Property="Image.Opacity" Value="0.25"></Setter>
        </DataTrigger>
    </Style.Triggers>
</Style>

这篇关于有没有办法使禁用的按钮上的图像饱和?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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