0

Hey I want to set color of BorderBrush in .xaml.cs file and don't want to use colours like Red or Green and want to use whole palette from HEX or RGB. I don't know how to covert it. Maybe you know how to solve this problem.

    private void TxbName_MouseEnter(object sender, MouseEventArgs e)
    {
        txbName.BorderBrush = Brushes.Green;
        txblImie.Foreground = Brushes.Red;
    }
Koza12
  • 11
  • 1

1 Answers1

4

You can use the ConvertFrom method from BrushConverter.

var converter=new BrushConverter();
txblImie.Foreground = (Brush)converter.ConvertFrom("#ff0000");
bolkay
  • 1,881
  • 9
  • 20
  • Error CS1002 ; expected Error CS1526 A new expression requires (), [], or {} after type Error CS0144 Cannot create an instance of the abstract class or interface 'Brush' Error CS0149 Method name expected It's not working:( – Koza12 Jul 07 '19 at 17:59