How can I make a WPF Image disableable?

前端 未结 5 1189
野趣味
野趣味 2021-01-21 04:54

I need an Image that is grayed out when disabled (IsEnabled=False). A grayed out version of the image can be produced by reading the BitmapImage into a FormatConvertedBitmap whi

5条回答
  •  一生所求
    2021-01-21 05:15

    Create a DisableableImage class that is a typical WPF control. Inside, place two elements: the image, and a rectangle that appears only when the control is disabled. The rectangle should be the same width and height as the image, and it should overlay the image. With a color of gray and an alpha of somewhere around 40%, you should get an effect similar to actually graying out the image -- without all the effort to actually modify the image itself.

提交回复
热议问题