c# - "Disabled"对图像的影响

标签 c# wpf image xaml button

在 Win Forms 中,当我禁用按钮时,其图像背景会转换为灰度图像。如何使用 XAML 代码在图像控件中模拟这种效果?

最佳答案

您可以像下面这样在按钮中设置图像的不透明度:

<Button>
  <Image Source="button.png">
    <Image.Style>
      <Style TargetType="Image">
        <Style.Triggers>
          <Trigger Property="IsEnabled" Value="False">
            <Setter Property="Opacity" Value="0.4" />
          </Trigger>
        </Style.Triggers>
      </Style>
    </Image.Style>
  </Image>
</Button>

关于c# - "Disabled"对图像的影响,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18815789/

相关文章:

图像溢出 flutter

c# - 使用 PowerShell 查找最接近的 System.Color 实例

c# - 如何获取迭代中的所有工作项?

wpf - 如何使用WPF(Powerboots)显示Twitter状态(伪HTML)

c# - WPF:缩放路径的正确方法?

php - 如何使用 PHP 在 MySQL 数据库中插入图像?

c# - 如何获取所有引用程序集的列表(已加载或未加载)

c# - 通过 http post 接收的值对于 AngularJS 和 Web api 2 为空

java - 如何为我的 SWT WPF 程序设置主题?

php - 从url中获取所有图片