convert from Color to brush

前端 未结 7 1968
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-08 03:39

How do I convert a Color to a Brush in C#?

7条回答
  •  生来不讨喜
    2020-12-08 04:19

    This is for Color to Brush....

    you can't convert it, you have to make a new brush....

    SolidColorBrush brush = new SolidColorBrush( myColor );
    

    now, if you need it in XAML, you COULD make a custom value converter and use that in a binding

提交回复
热议问题