CheckBoxEditorControl.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. using System.Windows.Media;
  4. namespace InABox.DynamicGrid
  5. {
  6. public class CheckBoxEditorControl : DynamicEditorControl<bool>
  7. {
  8. private CheckBox Editor;
  9. protected override FrameworkElement CreateEditor()
  10. {
  11. Editor = new CheckBox
  12. {
  13. VerticalAlignment = VerticalAlignment.Center,
  14. HorizontalAlignment = HorizontalAlignment.Stretch
  15. };
  16. Editor.Checked += (o, e) => CheckChanged();
  17. Editor.Unchecked += (o, e) => CheckChanged();
  18. return Editor;
  19. }
  20. public override int DesiredHeight()
  21. {
  22. return 25;
  23. }
  24. public override int DesiredWidth()
  25. {
  26. return 25;
  27. }
  28. protected override bool RetrieveValue()
  29. {
  30. return Editor.IsChecked == true;
  31. }
  32. protected override void UpdateValue(bool value)
  33. {
  34. Editor.IsChecked = value;
  35. }
  36. public override void SetFocus()
  37. {
  38. Editor.Focus();
  39. }
  40. public override void SetColor(Color color)
  41. {
  42. Editor.Background = new SolidColorBrush(color);
  43. }
  44. }
  45. }