标签:下拉列表 contains 显示 hang trigger err owa frame ide
public class ValueSelector : DataTemplateSelector
{
public ValueSelector()
{
}
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
DataTemplate dt = new DataTemplate();
List<MDGHelper.Row> list = new List<MDGHelper.Row>();
var mapping = MDGHelper.Mapping[GlobalVariable.IAML_MDGDiagram];
for (int i = 0; i < mapping.TaggedValueTypes.RefData.DataSet.Rows.Count; i++)
{
list.Add(mapping.TaggedValueTypes.RefData.DataSet.Rows[i]);
}
Dictionary<string, string> dicType = new Dictionary<string, string>();
Dictionary<string, string> dicData = new Dictionary<string, string>();
dicType.Clear();
dicData.Clear();
if (item != null && item is EditGridCellData)
{
EditGridCellData cellDatas = item as EditGridCellData;
TaggedValueModel taggedValueModel = cellDatas.RowData.Row as TaggedValueModel;
//Window window = Application.Current.MainWindow;
for (int i = 0; i < list.Count; i++)
{
dicType.Add(list[i].Columns[0].value, list[i].Columns[1].value);
}
for (int i = 0; i < list.Count; i++)
{
dicData.Add(list[i].Columns[0].value, list[i].Columns[2].value);
}
if (dicType.ContainsKey(taggedValueModel.Property) && dicType[taggedValueModel.Property] == "Enum")
{
//实例化下拉列表框控件
FrameworkElementFactory comboBoxEdit = new FrameworkElementFactory(typeof(ComboBoxEdit));
comboBoxEdit.SetBinding(ComboBoxEdit.ItemsSourceProperty, new Binding()
{
Path = new PropertyPath("TaggedValues"),
Mode = BindingMode.TwoWay,
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
});
comboBoxEdit.SetValue(ComboBoxEdit.MarginProperty, new Thickness(0));
dt.VisualTree = comboBoxEdit;
}
else
{
//实例化文本控件
FrameworkElementFactory txtBox = new FrameworkElementFactory(typeof(TextBox));
txtBox.SetBinding(TextBox.TextProperty, new Binding()
{
Path = new PropertyPath("Property"),
Mode = BindingMode.TwoWay,
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
});
txtBox.SetValue(TextBox.ForegroundProperty, Brushes.Black);
txtBox.SetValue(TextBox.BackgroundProperty, new SolidColorBrush(Colors.Transparent));
dt.VisualTree = txtBox;
}
}
return dt;
}
}
DevExpress中 的DataGrid每一行根据其类型显示控件的种类
标签:下拉列表 contains 显示 hang trigger err owa frame ide
原文地址:https://www.cnblogs.com/zhaiganggang/p/12344523.html