DynamicFormControl.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using InABox.Core;
  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. namespace InABox.DynamicGrid
  9. {
  10. public abstract class DynamicFormControl : ContentControl
  11. {
  12. public DynamicFormDesignGrid FormDesignGrid { get; set; }
  13. protected abstract FrameworkElement Create();
  14. public abstract void SetControl(DFLayoutControl control);
  15. }
  16. public abstract class DynamicFormControl<TControl> : DynamicFormControl
  17. where TControl : DFLayoutControl
  18. {
  19. private TControl control;
  20. public TControl Control
  21. {
  22. get => control;
  23. set
  24. {
  25. control = value;
  26. Content = Create();
  27. AfterSetControl(control);
  28. }
  29. }
  30. protected virtual void AfterSetControl(TControl control)
  31. {
  32. }
  33. public override void SetControl(DFLayoutControl control) => Control = (TControl)control;
  34. }
  35. }