Thursday, April 21, 2011

How to set Border.BorderBrush from string

Theres a problem. I can't set value of BorderBrush fros C#-code (not in XAML):

 ((Border)((Image)sender).Parent).BorderBrush = "#FFBCC7D8";

How to solve this problem?

From stackoverflow
  • You must use an Converter to convert the string to a Brush-Object. In the Framework there is a BrushConverter to do this.

    BrushConverter converter = new BrushConverter();
    ((Border)((Image)sender).Parent).BorderBrush = converter.ConvertFromString("#FFBCC7D8") as Brush;
    

0 comments:

Post a Comment