加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 如何使WPF图像无法使用?

发布时间:2020-12-15 19:42:17 所属栏目:百科 来源:网络整理
导读:我需要一个在禁用时灰显的图像(IsEnabled = False).通过将Bitmap Image读入FormatConvertedBitmap(显示为 here),可以生成图像的灰色版本. 我已经能够使用UserControl,但现在我想在专门的Image类中使用相同的行为以获得更大的灵活性.我不在乎这是在XAML,代码
我需要一个在禁用时灰显的图像(IsEnabled = False).通过将Bitmap Image读入FormatConvertedBitmap(显示为 here),可以生成图像的灰色版本.

我已经能够使用UserControl,但现在我想在专门的Image类中使用相同的行为以获得更大的灵活性.我不在乎这是在XAML,代码隐藏还是两者中实现,但它需要是Image的子类.

用法可能是:

<DisableableImage Source="Images/image1.png" />
<DisableableImage Source="Images/image1.png" IsEnabled="False" />

<!-- Since IsEnabled is inherited down the tree,the image will be grayed out like the rest of the button -->
<Button IsEnabled="False">
    <StackPanel Orientation="Horizontal">
        <TextBlock>OK</TextBlock>
        <DisableableImage Source="Images/ok.png" />
    </StackPanel>
</Button>

解决方法

看看 this link

编辑:
或者this one(你需要的只是AutoGreyableImage类)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读