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;