CustomSwitch.xaml.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. namespace CyberX8_Themes.UserControls
  16. {
  17. /// <summary>
  18. /// CustomSwitch.xaml 的交互逻辑
  19. /// </summary>
  20. public partial class CustomSwitch : UserControl
  21. {
  22. public CustomSwitch()
  23. {
  24. InitializeComponent();
  25. }
  26. public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
  27. "Value", typeof(string), typeof(CustomSwitch));
  28. public string Value
  29. {
  30. get { return (string)this.GetValue(ValueProperty); }
  31. set { this.SetValue(ValueProperty, value); }
  32. }
  33. public static readonly DependencyProperty IsOpenProperty = DependencyProperty.Register(
  34. "IsOpen", typeof(bool), typeof(CustomSwitch));
  35. public bool IsOpen
  36. {
  37. get
  38. {
  39. return (bool)this.GetValue(IsOpenProperty);
  40. }
  41. set
  42. {
  43. this.SetValue(IsOpenProperty, value);
  44. }
  45. }
  46. private void toggleButton_Click(object sender, RoutedEventArgs e)
  47. {
  48. if (toggleButton.IsChecked == true)
  49. {
  50. //ellipse.Fill = Brushes.Green;
  51. IsOpen = true;
  52. }
  53. else
  54. {
  55. //ellipse.Fill = Brushes.Silver;
  56. IsOpen = false;
  57. }
  58. }
  59. }
  60. }