public SceneNode CreateBindingOrData(SceneNode target, IPropertyId targetProperty, DataSchemaNodePath bindingPath, bool useSourceInherited) { BindingSceneNode bindingSceneNode; if (!useSourceInherited || !this.SetSourceAsDataContext(target, targetProperty, ref bindingPath, false)) { SceneNode dataSource = this.CreateDataSource(target, bindingPath, false); bindingSceneNode = dataSource as BindingSceneNode; if (bindingSceneNode == null) { return(dataSource); } } else { bindingSceneNode = BindingSceneNode.Factory.Instantiate(target.ViewModel); } string path = bindingPath.Path; if (bindingPath.Schema is XmlSchema) { bindingSceneNode.XPath = path; } else if (!string.IsNullOrEmpty(path)) { bindingSceneNode.SetPath(path); } BindingModeInfo defaultBindingMode = BindingPropertyHelper.GetDefaultBindingMode(target.DocumentNode, targetProperty, bindingPath); if (!defaultBindingMode.IsOptional) { bindingSceneNode.Mode = defaultBindingMode.Mode; } return((SceneNode)bindingSceneNode); }
private void CreateFieldElement(DataViewBuilderContext context, DataViewTemplateEntry templateEntry) { context.CurrentFieldNode = (DocumentCompositeNode)templateEntry.FieldNode.Clone(context.DocumentContext); DocumentCompositeNode documentCompositeNode = (DocumentCompositeNode)context.CurrentFieldNode.Properties[(IPropertyId)templateEntry.FieldValueProperty]; string path = context.CurrentSchemaPath.Path; if (context.CurrentSchemaPath.Schema is XmlSchema) { string str = path ?? string.Empty; documentCompositeNode.Properties[BindingSceneNode.XPathProperty] = (DocumentNode)context.DocumentContext.CreateNode(str); } else if (!string.IsNullOrEmpty(path)) { object obj = this.Platform.Metadata.MakePropertyPath(path); documentCompositeNode.Properties[BindingSceneNode.PathProperty] = context.DocumentContext.CreateNode(obj.GetType(), obj); } BindingModeInfo defaultBindingMode = BindingPropertyHelper.GetDefaultBindingMode((DocumentNode)templateEntry.FieldNode, (IPropertyId)templateEntry.FieldValueProperty, context.CurrentSchemaPath); if (defaultBindingMode.IsOptional) { return; } DocumentPrimitiveNode node = context.DocumentContext.CreateNode(PlatformTypes.BindingMode, (IDocumentNodeValue) new DocumentNodeStringValue(defaultBindingMode.Mode.ToString())); documentCompositeNode.Properties[BindingSceneNode.ModeProperty] = (DocumentNode)node; }
private SceneNode CreateDataGridBoundColumn(DataSchemaNodePath schemaPath, ITypeId columnType) { DataGridColumnNode dataGridColumnNode = (DataGridColumnNode)this.DragModel.ViewModel.CreateSceneNode(columnType); string columnName = DataBindingDragDropDefaultHandler.GetColumnName(schemaPath); dataGridColumnNode.SetLocalValue(DataGridColumnNode.ColumnHeaderProperty, (object)columnName); BindingSceneNode bindingSceneNode = (BindingSceneNode)this.DragModel.ViewModel.CreateSceneNode(PlatformTypes.Binding); bindingSceneNode.SetPath(schemaPath.Path); BindingModeInfo defaultBindingMode = BindingPropertyHelper.GetDefaultBindingMode(dataGridColumnNode.DocumentNode, DataGridColumnNode.BoundColumnBindingProperty, schemaPath); if (!defaultBindingMode.IsOptional) { bindingSceneNode.Mode = defaultBindingMode.Mode; } dataGridColumnNode.SetValueAsSceneNode(DataGridColumnNode.BoundColumnBindingProperty, (SceneNode)bindingSceneNode); return((SceneNode)dataGridColumnNode); }