silverlight 各种常用应用
一 背景颜色
这里以按钮为例:
1、设置背景颜色
//通过包装的属性设置按钮的背景颜色
btn_ButtonC.Background = new SolidColorBrush(Colors.Red);
或者 menujbsz.Background = new SolidColorBrush(Color.FromArgb(47,0,255,255));
// 通过依赖性属性的SetValue设置按钮的背景颜色
SolidColorBrush brush = new SolidColorBrush(Colors.Blue);
btn_ButtonD.SetValue(
Button.BackgroundProperty, brush);
2、获取背景颜色
// 通过包装的属性获取ButtonB的背景颜色
SolidColorBrush b_Brush1 = (SolidColorBrush) (btn_ButtonB.Background);
txt_Value1.Text = b_Brush1.Color.ToString();
// 通过依赖性属性的 GetValue获取ButtonB的背景颜色
SolidColorBrush b_Brush2 = (SolidColorBrush) (btn_ButtonB.GetValue(
Button.BackgroundProperty));
txt_Value2.Text = b_Brush2.Color.ToString();