PMTemplateSelector.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  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 VirgoUI.Client.Models.PMs
  9. {
  10. public class PMTemplateSelector : DataTemplateSelector
  11. {
  12. public DataTemplate DefaultTemplate { get; set; }
  13. public DataTemplate ShareTemplate { get; set; }
  14. public DataTemplate DropDownListTemplate { get; set; }
  15. public override DataTemplate SelectTemplate(object item, DependencyObject container)
  16. {
  17. PMParameter m_value = item as PMParameter;
  18. if (m_value != null)
  19. {
  20. switch (m_value.Type)
  21. {
  22. case ParameterType.Share:
  23. return ShareTemplate;
  24. case ParameterType.DropDownList:
  25. return DropDownListTemplate;
  26. default:
  27. return DefaultTemplate;
  28. }
  29. }
  30. else
  31. return null;
  32. }
  33. }
  34. }