protected void SetCommonBindingValues(BindingSceneNode binding) { IDocumentContext documentContext = binding.DocumentContext; bool flag = !string.IsNullOrEmpty(binding.Path) || binding.SupportsXPath && !string.IsNullOrEmpty(binding.XPath); BindingMode bindingMode = this.CurrentBindingMode; if (!flag && (bindingMode == BindingMode.Default || bindingMode == BindingMode.OneWayToSource || bindingMode == BindingMode.TwoWay)) { bindingMode = BindingMode.OneWay; } if (bindingMode == BindingMode.TwoWay && binding.SupportsUpdateSourceTrigger) { if (binding.GetDefaultValue(BindingSceneNode.UpdateSourceTriggerProperty) == this.CurrentUpdateSourceTrigger) { binding.ClearLocalValue(BindingSceneNode.UpdateSourceTriggerProperty); } else { binding.UpdateSourceTrigger = this.CurrentUpdateSourceTrigger; } } BindingModeInfo defaultBindingMode = BindingPropertyHelper.GetDefaultBindingMode(this.TargetElement.DocumentNode, (IPropertyId)this.TargetProperty, this.CurrentDataPath); if (defaultBindingMode.IsOptional && defaultBindingMode.Mode == bindingMode) { binding.ClearLocalValue(BindingSceneNode.ModeProperty); } else { binding.Mode = bindingMode; } if (!string.IsNullOrEmpty(this.BindingFallbackValue)) { binding.FallbackValue = (DocumentNode)documentContext.CreateNode(this.BindingFallbackValue); } SceneNode sceneNode = (SceneNode)null; if (this.CurrentValueConverter != null) { sceneNode = this.CurrentValueConverter.GenerateConverter(); } else if (this.originalValueConverter != null) { sceneNode = this.ViewModel.GetSceneNode(this.originalValueConverter.Clone(binding.DocumentContext)); } if (sceneNode != null) { binding.SetValueAsSceneNode(BindingSceneNode.ConverterProperty, sceneNode); } if (string.IsNullOrEmpty(this.valueConverterParameter)) { return; } binding.ConverterParameter = (object)this.valueConverterParameter; }
private bool UpdateInvokeCommandAction(SceneNode actionNode) { if (!ProjectNeutralTypes.InvokeCommandAction.IsAssignableFrom((ITypeId)actionNode.Type)) { return(false); } DataSchemaNodePath primaryAbsolutePath = this.DragModel.DataSource.PrimaryAbsolutePath; BindingSceneNode bindingSceneNode = this.DragModel.ViewModel.BindingEditor.CreateAndSetBindingOrData(actionNode, DataBindingDragDropAddTriggerHandler.CommandProperty, primaryAbsolutePath) as BindingSceneNode; if (bindingSceneNode == null) { return(false); } bindingSceneNode.ClearLocalValue(BindingSceneNode.ModeProperty); return(true); }
private bool UpdateCallMethodAction(SceneNode actionNode) { if (!ProjectNeutralTypes.CallMethodAction.IsAssignableFrom((ITypeId)actionNode.Type)) { return(false); } DataSchemaNodePath primaryAbsolutePath = this.DragModel.DataSource.PrimaryAbsolutePath; DataSchemaNode node = primaryAbsolutePath.Node; DataSchemaNodePath bindingPath = new DataSchemaNodePath(primaryAbsolutePath.Schema, node.Parent); BindingSceneNode bindingSceneNode = this.DragModel.ViewModel.BindingEditor.CreateAndSetBindingOrData(actionNode, DataBindingDragDropAddTriggerHandler.TargetObjectProperty, bindingPath) as BindingSceneNode; if (bindingSceneNode == null) { return(false); } bindingSceneNode.ClearLocalValue(BindingSceneNode.ModeProperty); actionNode.SetValue(DataBindingDragDropAddTriggerHandler.MethodNameProperty, (object)node.PathName); return(true); }