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
编辑: (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |