DFFieldPlaceholderControl.cs 1.2 KB

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