WPF 修改button按钮颜色的方式  跟C#略有区别,一下总价几种方式;20170802 姜彦
 
1.颜色简称
Button.Background = System.Windows.Media.Brushes.ForestGreen;

 

2.颜色代码
 
A:
           
 BrushConverter conv = new BrushConverter();
            Brush bru = conv.ConvertFromInvariantString("#FF255687") as Brush;
            btnSave.Background = (System.Windows.Media.Brush)bru;
 

 

B:
SolidColorBrush myBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0xFF, 0x25, 0x56, 0x87));
btnSave.Background = (System.Windows.Media.Brush)myBrush;

 

 

相关文章: