chr
2024-11-02 b5234c5ab1e9e6826b8d8fc1e95fa752aaa40b74
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using PdmSwPlugin.Common.Entity;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
 
namespace PdmSwPlugin.MaterialSelect.Resource
{
    /// <summary>
    /// 规格的动态渲染
    /// </summary>
    public class CellTypeSelector : DataTemplateSelector
    {
        public DataTemplate ComboBox { get; set; }
        public DataTemplate Input { get; set; }
 
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item is PartSpec)
            {
                PartSpec spec = item as PartSpec;
                if (spec.type == "select")
                {
                    string[] values = spec.json.Split(',');
                    ObservableCollection<string> valueList = new ObservableCollection<string>(values);
                    valueList.Insert(0, "");
                    spec.valueList = valueList;
                    return ComboBox;
                }
                return Input;
            }
            else {
                return Input;
            }
        }
    }
}