简体   繁体   中英

Binding colors of shapes with variables c#

How I can bind colour of rectangle and my bool in c# code if i arledy have converter? I dont have rectange in xaml, I just creating it in code and adding on grid.

See your other question

To add a binding in code:

    Binding binding = new Binding("State");
    binding.Converter = new BooleanToBrushConverter();
    _rectangle.SetBinding(Rectangle.FillProperty, binding);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM