SwitchPropertyEditor.cs 579 B

1234567891011121314151617
  1. using System.Windows;
  2. using System.Windows.Controls.Primitives;
  3. using HandyControl.Tools;
  4. namespace HandyControl.Controls;
  5. public class SwitchPropertyEditor : PropertyEditorBase
  6. {
  7. public override FrameworkElement CreateElement(PropertyItem propertyItem) => new ToggleButton
  8. {
  9. Style = ResourceHelper.GetResourceInternal<Style>("ToggleButtonSwitch"),
  10. HorizontalAlignment = HorizontalAlignment.Left,
  11. IsEnabled = !propertyItem.IsReadOnly
  12. };
  13. public override DependencyProperty GetDependencyProperty() => ToggleButton.IsCheckedProperty;
  14. }