private void CommonPropertyWin_Loaded(object sender, RoutedEventArgs e) { MethodInfo mi = typeof(iS3Property).GetMethod("GetProperty").MakeGenericMethod(_type); _propertyDefs = mi.Invoke(new iS3Property(), new object[] { Activator.CreateInstance(_type) }) as List <PropertyDef>; PropertyHolder.Children.Clear(); for (int i = 1; i < PropertyTC.Items.Count; i++) { PropertyTC.Items.RemoveAt(1); } foreach (PropertyDef def in _propertyDefs) { ObjectsDefinition _objdef = Globals.project.domains.FirstOrDefault(x => x.name == _domain).objectsDefinitions.FirstOrDefault(x => x.Type == _objType); DGObjectMeta judgeobj = _objdef.Metas.FirstOrDefault(x => x.PropertyName == def.key); if (null != judgeobj) { AddStackPanel(judgeobj, def); } } }
public void AddStackPanel(DGObjectMeta _meta, PropertyDef def) { StackPanel stackPanel = new StackPanel(); stackPanel.Orientation = Orientation.Horizontal; TextBlock keyTB = new TextBlock() { Text = _meta.ChsName }; keyTB.Width = 150; stackPanel.Children.Add(keyTB); TextBox valueTB = new TextBox() { Text = def.value }; TBDict[def.id] = valueTB; valueTB.Width = 200; stackPanel.Children.Add(valueTB); PropertyHolder.Children.Add(stackPanel); }
private void DGObjectDataGrid_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e) { // "Graphics" and "Attributes" are used internally. try { if (e.PropertyName == "Graphics" || e.PropertyName == "Attributes" || e.PropertyName == "IsSelected" || e.PropertyName == "OBJECTID" || e.PropertyName == "SHAPE" || e.PropertyName == "Shape" || e.PropertyName == "SHAPE_Length" || e.PropertyName == "Shape_Length" || e.PropertyName == "SHAPE_Area" || e.PropertyName == "Shape_AreA" || e.PropertyName == "ID" || e.PropertyName == "parent" || e.PropertyName == "name" ) { e.Cancel = true; return; } else { DGObjectMeta _meta = objs.definition.Metas.FirstOrDefault(x => x.PropertyName == e.PropertyName); string _name = null; if (null != _meta) { _name = _meta.ChsName; } if (null != _name) { e.Column.Header = _name; } else { e.Cancel = true; } return; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } //DataGridTextColumn tcol = e.Column as DataGridTextColumn; //if (tcol == null) // return; //// Does the column data type contain the ICollection interface? //// If yes, we need the CollectionValueConverter to display data. //if (typeof(ICollection).IsAssignableFrom(e.PropertyType)) //{ // Binding binding = tcol.Binding as Binding; // binding.Converter = _objectConverter; //} //// Is the column data class type other than String? //// If yes, we need the ClassValueConverter to display data. //else if (e.PropertyType.IsClass && e.PropertyType.Name != "String") //{ // Binding binding = tcol.Binding as Binding; // binding.Converter = _objectConverter; //} }