DynamicFormControl.cs 942 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using InABox.Core;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. namespace InABox.DynamicGrid
  10. {
  11. public abstract class DynamicFormControl : ContentControl
  12. {
  13. public DynamicFormDesignGrid FormDesignGrid { get; set; }
  14. protected abstract FrameworkElement Create();
  15. public abstract void SetControl(DFLayoutControl control);
  16. }
  17. public abstract class DynamicFormControl<TControl> : DynamicFormControl
  18. where TControl : DFLayoutControl
  19. {
  20. private TControl control;
  21. public TControl Control
  22. {
  23. get => control;
  24. set
  25. {
  26. control = value;
  27. Content = Create();
  28. }
  29. }
  30. public override void SetControl(DFLayoutControl control) => Control = (TControl)control;
  31. }
  32. }