void OnCreateDynamicArgumentExecute(object sender, ExecutedRoutedEventArgs e)
        {
            DynamicArgumentWrapperObject wrapper = new DynamicArgumentWrapperObject();

            this.DynamicArguments.Add(wrapper);
            this.dgHelper.BeginRowEdit(wrapper);
        }
 //Hook LoadingRow event to set different row template (<Click here to add new item>) for new place holder
 void DataGrid_Standard_LoadingRow(object sender, DataGridRowEventArgs e)
 {
     if (e.Row.Item != CollectionView.NewItemPlaceholder)
     {
         DynamicArgumentWrapperObject wrapper = e.Row.Item as DynamicArgumentWrapperObject;
         wrapper.Row = e.Row;
     }
 }
        static void OnArgumentPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            DynamicArgumentWrapperObject wrapper = (DynamicArgumentWrapperObject)sender;

            if (!wrapper.IsValidating && !wrapper.isInitializing)
            {
                wrapper.OnArgumentPropertyChanged(e);
            }
        }
        internal void ValidateEntry(DynamicArgumentWrapperObject entry, DependencyPropertyChangedEventArgs e)
        {
            if (e.Property == DynamicArgumentWrapperObject.NameProperty)
            {
                if (this.IsDictionary.Value)
                {
                    DataGridRow row     = entry.Row;
                    string      newName = e.NewValue as string;

                    bool duplicates =
                        this.DynamicArguments.Any <DynamicArgumentWrapperObject>(
                            p => string.Equals(p.Name, newName) && p != entry);
                    if (duplicates || string.IsNullOrEmpty(newName))
                    {
                        entry.Name = e.OldValue as string;
                        if (duplicates)
                        {
                            ErrorReporting.ShowErrorMessage(string.Format(CultureInfo.CurrentCulture, SR.DuplicateArgumentName, newName));
                        }
                        else
                        {
                            ErrorReporting.ShowErrorMessage(string.Format(CultureInfo.CurrentCulture, SR.EmptyArgumentName));
                        }
                    }
                    entry.IsValidating = false;
                }
            }
            else
            {
                if (e.Property == DynamicArgumentWrapperObject.DirectionProperty)
                {
                    entry.UseLocationExpression = (entry.Direction != ArgumentDirection.In);
                }
                if ((e.Property != DynamicArgumentWrapperObject.ExpressionProperty) && (entry.Expression != null))
                {
                    ActivityWithResult expression = entry.Expression.GetCurrentValue() as ActivityWithResult;
                    if (expression != null)
                    {
                        ActivityWithResult newExpression;
                        if (ExpressionHelper.TryMorphExpression(expression, entry.UseLocationExpression, entry.Type, this.Context, out newExpression))
                        {
                            entry.Expression = (this.OwnerActivity as IModelTreeItem).ModelTreeManager.WrapAsModelItem(newExpression);
                        }
                        else
                        {
                            //Microsoft

                            entry.Expression = null;
                        }
                    }
                }
                entry.IsValidating = false;
            }
        }
 void OnCreateDynamicArgumentExecute(object sender, ExecutedRoutedEventArgs e)
 {
     DynamicArgumentWrapperObject wrapper = new DynamicArgumentWrapperObject();
     this.DynamicArguments.Add(wrapper);
     this.dgHelper.BeginRowEdit(wrapper);
 }
        internal void ValidateEntry(DynamicArgumentWrapperObject entry, DependencyPropertyChangedEventArgs e)
        {
            if (e.Property == DynamicArgumentWrapperObject.NameProperty)
            {
                if (this.IsDictionary.Value)
                {
                    DataGridRow row = entry.Row;
                    string newName = e.NewValue as string;

                    bool duplicates =
                        this.DynamicArguments.Any<DynamicArgumentWrapperObject>(
                            p => string.Equals(p.Name, newName) && p != entry);
                    if (duplicates || string.IsNullOrEmpty(newName))
                    {
                        entry.Name = e.OldValue as string;
                        if (duplicates)
                        {
                            ErrorReporting.ShowErrorMessage(string.Format(CultureInfo.CurrentCulture, SR.DuplicateArgumentName, newName));
                        }
                        else
                        {
                            ErrorReporting.ShowErrorMessage(string.Format(CultureInfo.CurrentCulture, SR.EmptyArgumentName));
                        }
                    }
                    entry.IsValidating = false;
                }
            }
            else
            {
                if (e.Property == DynamicArgumentWrapperObject.DirectionProperty)
                {
                    entry.UseLocationExpression = (entry.Direction != ArgumentDirection.In);
                }                
                if ((e.Property != DynamicArgumentWrapperObject.ExpressionProperty) && (entry.Expression != null))
                {
                    ActivityWithResult expression = entry.Expression.GetCurrentValue() as ActivityWithResult;                    
                    if (expression != null)
                    {
                        ActivityWithResult newExpression;
                        if (ExpressionHelper.TryMorphExpression(expression, entry.UseLocationExpression, entry.Type, this.Context, out newExpression))
                        {
                            entry.Expression = (this.OwnerActivity as IModelTreeItem).ModelTreeManager.WrapAsModelItem(newExpression);
                        }
                        else
                        {
                            //[....] 

                            entry.Expression = null;
                        }
                    }
                }
                entry.IsValidating = false;
            }
        }