更改silverlight中的切换按钮背景颜色

时间:2016-09-07 05:57:11

标签: c# silverlight

切换按钮背景颜色应在其click / IsChecked事件中更改。 请查看以下代码:

<ToggleButton x:Name="BtnArea" Content="{Binding Area, Source={StaticResource Labels}}" Style="{StaticResource FirstButton}" Click="Toggle_Click"  Background="Chocolate" />


 private void Toggle_Click(object sender, RoutedEventArgs e)
        {
            ToggleButton obj = (ToggleButton)sender;
            ((ToggleButton)sender).Background = new SolidColorBrush(Color.FromArgb(155, 0, 255, 0));
            obj.Background = new SolidColorBrush(Color.FromArgb(155, 0, 55, 0));
        }

0 个答案:

没有答案