WPF-后台设置控件Background

燕志学
2023-12-01

方法一:

    buttonName.Background = Brushes.Red;

方法二:

    buttonName.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF3D3D3D"));

方法三:

    buttonName.Background = new SolidColorBrush(Colors.White);

方法四:

    var bc = new BrushConverter();

    buttonName.Background = (Brush)bc.ConvertFrom("#FF3D3D3D");

方法五:

    Brush br = new SolidColorBrush(Color.FromArgb(A, R, G, B));

    buttonName.Background = br;

 类似资料: