WPF Binding to change fill color of ellipse

后端 未结 3 1256
臣服心动
臣服心动 2021-02-13 12:44

How do I programmatically change the color of an ellipse that is defined in XAML based on a variable?

Everything I\'ve read on binding is based on collections and lists

3条回答
  •  南方客
    南方客 (楼主)
    2021-02-13 13:24

    use

    System.Windows.Media
    

    If the name of your ellipse in your XAML is my_ellipse,
    write something like this:

    my_ellipse.Fill = System.Windows.Media.Brushes.Red;
    

    or this:

    my_ellipse.Fill = (SolidColorBrush)new BrushConverter().ConvertFromString("#F4F4F5")
    

提交回复
热议问题