private DocumentCompositeNode GenerateDataTemplateIfNeeded(SceneNode targetNode, ITypeId dataTemplateType) { if (this.DragModel.RelativeDropSchemaPath.IsProperty) { return((DocumentCompositeNode)null); } IList <DataSchemaNodePath> relativeSchemaPaths = this.GetRelativeSchemaPaths(); if (relativeSchemaPaths.Count == 0) { return((DocumentCompositeNode)null); } DocumentCompositeNode dataTemplateNode = (DocumentCompositeNode)null; using (SceneEditTransaction editTransaction = this.DragModel.Document.CreateEditTransaction(StringTable.UndoUnitCreateTemplate)) { DataSchemaNode node = this.DragModel.RelativeDropSchemaPath.Node; DataSchemaNode dataSchemaNode = node.CollectionItem ?? node; string str = ((dataSchemaNode.Type != (Type)null ? dataSchemaNode.Type.Name : dataSchemaNode.PathName) + "Template").TrimStart('@', '/'); if (!SceneNodeIDHelper.IsCSharpID(str)) { str = "DataTemplate"; } dataTemplateNode = DataViewFactory.CreateDataTemplateResource(targetNode, ItemsControlElement.ItemTemplateProperty, str, relativeSchemaPaths, DataViewCategory.DataTemplate, dataTemplateType); editTransaction.Update(); this.ApplyActiveUserThemeStyleToDataTemplate(dataTemplateNode); editTransaction.Commit(); } return(dataTemplateNode); }
private SceneNode CreateDataGridTemplateColumn(DataSchemaNodePath schemaPath) { DataGridColumnNode dataGridColumnNode = (DataGridColumnNode)this.DragModel.ViewModel.CreateSceneNode(ProjectNeutralTypes.DataGridTemplateColumn); string columnName = DataBindingDragDropDefaultHandler.GetColumnName(schemaPath); dataGridColumnNode.SetLocalValue(DataGridColumnNode.ColumnHeaderProperty, (object)columnName); string resourceNameBase = columnName + "Template"; List <DataSchemaNodePath> list = new List <DataSchemaNodePath>() { schemaPath }; DataViewFactory.CreateDataTemplateResource((SceneNode)dataGridColumnNode, DataGridColumnNode.TemplateColumnCellTemplateProperty, resourceNameBase, (IList <DataSchemaNodePath>)list, DataViewCategory.DataTemplate, PlatformTypes.DataTemplate); return((SceneNode)dataGridColumnNode); }