DFFieldPlaceholderControl.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  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. using System.Windows.Media;
  10. using System.Windows.Media.Imaging;
  11. namespace InABox.DynamicGrid
  12. {
  13. public class DFFieldPlaceholderControl<TField> : DynamicFormControl<TField>
  14. where TField : DFLayoutField
  15. {
  16. protected override FrameworkElement Create()
  17. {
  18. var result = new Border();
  19. result.Child = new Label
  20. {
  21. Content = string.Format("[{0}]", Control.Name),
  22. HorizontalContentAlignment = HorizontalAlignment.Center,
  23. VerticalContentAlignment = VerticalAlignment.Center,
  24. FontWeight = FontWeights.DemiBold
  25. };
  26. var code = Control.Name; // GetPropertyValue<String>("Code");
  27. var variable = FormDesignGrid.Variables.FirstOrDefault(x => string.Equals(x.Code, code));
  28. result.Background = variable != null ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Colors.Red);
  29. result.BorderBrush = BorderBrush;
  30. result.BorderThickness = new Thickness(0.75);
  31. return result;
  32. }
  33. }
  34. }