//Creating a loaded event private void RadioButtonOnLoad(object sender, RoutedEventArgs e) { Console.WriteLine("I am loaded"); SwitchButton myPanel = sender as SwitchButton; //myPanel.IsChecked = true; Console.WriteLine(myPanel.Disabled); //Getting the initial Background color.. myPanel.PrevCheck = myPanel.Disabled; //myPanel.Disabled = false; }
public static void OnCheckedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { //Checking the IsChecked property.... Console.WriteLine("Checked value has been change.."); SwitchButton myButton = sender as SwitchButton; Console.WriteLine(myButton.PrevCheck); Console.WriteLine(myButton.Disabled); if ((myButton.Disabled == true) && (myButton.PrevCheck == false)) { Console.WriteLine("I am inside disabled color"); myButton.DisableColor = myButton.Background; myButton.EnableColor = new SolidColorBrush(Color.FromRgb(219, 219, 224)); } else if ((myButton.Disabled == false) && (myButton.PrevCheck == true)) { Console.WriteLine("I am inside Enabled color"); myButton.DisableColor = new SolidColorBrush(Color.FromRgb(219, 219, 224)); myButton.EnableColor = myButton.Background; } //Changing the PrevCheck value myButton.PrevCheck = myButton.Disabled; Console.WriteLine("Previous value " + myButton.PrevCheck); }