1 //------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //------------------------------------------------------------
5 namespace System.Activities.Presentation
7 using System.Activities.Presentation.Model;
8 using System.Activities.Presentation.View;
9 using System.Activities.Presentation.Hosting;
11 using System.Collections;
12 using System.Collections.ObjectModel;
13 using System.Collections.Generic;
14 using System.Collections.Specialized;
15 using System.ComponentModel;
17 using System.Globalization;
19 using System.Windows.Controls;
20 using System.Windows.Data;
21 using System.Windows.Input;
22 using System.Windows.Threading;
23 using System.Reflection;
25 internal sealed partial class DynamicArgumentDesigner : UserControl
27 public static readonly DependencyProperty ContextProperty =
28 DependencyProperty.Register("Context",
29 typeof(EditingContext),
30 typeof(DynamicArgumentDesigner));
32 public static readonly DependencyProperty OwnerActivityProperty =
33 DependencyProperty.Register("OwnerActivity",
35 typeof(DynamicArgumentDesigner));
37 public static readonly DependencyProperty IsDirectionReadOnlyProperty =
38 DependencyProperty.Register("IsDirectionReadOnly",
40 typeof(DynamicArgumentDesigner),
41 new UIPropertyMetadata(true, OnIsDirectionReadOnlyChanged));
43 public static readonly DependencyProperty DynamicArgumentsProperty =
44 DependencyProperty.Register("DynamicArguments",
45 typeof(ObservableCollection<DynamicArgumentWrapperObject>),
46 typeof(DynamicArgumentDesigner),
47 new PropertyMetadata(new ObservableCollection<DynamicArgumentWrapperObject>()));
49 public static readonly DependencyProperty IsDictionaryProperty =
50 DependencyProperty.Register("IsDictionary",
52 typeof(DynamicArgumentDesigner),
53 new PropertyMetadata(false));
55 public static readonly DependencyProperty UnderlyingArgumentTypeProperty =
56 DependencyProperty.Register("UnderlyingArgumentType",
58 typeof(DynamicArgumentDesigner),
59 new PropertyMetadata(typeof(Argument)));
61 public static readonly RoutedCommand CreateDynamicArgumentCommand = new RoutedCommand("CreateDynamicArgumentCommand", typeof(DynamicArgumentDesigner));
62 public static readonly RoutedCommand MoveUpArgumentCommand = new RoutedCommand("MoveUpArgumentCommand", typeof(DynamicArgumentDesigner));
63 public static readonly RoutedCommand MoveDownArgumentCommand = new RoutedCommand("MoveDownArgumentCommand", typeof(DynamicArgumentDesigner));
64 public static readonly RoutedCommand DeleteArgumentCommand = new RoutedCommand("DeleteArgumentCommand", typeof(DynamicArgumentDesigner));
65 public const string DefaultArgumentPrefix = "Argument";
67 SubscribeContextCallback<ReadOnlyState> onReadOnlyStateChangedCallback;
69 static readonly Type InArgumentType = typeof(InArgument);
70 static readonly Type OutArgumentType = typeof(OutArgument);
71 static readonly Type InOutArgumentType = typeof(InOutArgument);
72 static readonly Type ArgumentType = typeof(Argument);
74 const int NameColumn = 0;
75 const int DirectionColumn = 1;
76 const int ArgumentTypeColumn = 2;
77 const int ExpressionColumn = 3;
81 string argumentPrefix = DefaultArgumentPrefix;
83 DataGridHelper dgHelper;
84 ContextItemManager contextItemManager;
86 public DynamicArgumentDesigner()
88 InitializeComponent();
90 this.dgHelper = new DataGridHelper(this.WPF_DataGrid, this);
91 this.dgHelper.AddNewRowCommand = DynamicArgumentDesigner.CreateDynamicArgumentCommand;
94 this.WPF_DataGrid.LoadingRow += this.DataGrid_Standard_LoadingRow;
96 this.Loaded += (sender, e) =>
98 OnReadOnlyStateChanged(new ReadOnlyState());
99 this.ContextItemManager.Subscribe<ReadOnlyState>(this.OnReadOnlyStateChangedCallback);
100 this.OnDynamicArgumentsLoaded();
101 this.OnUnderlyingArgumentTypeChanged();
103 this.Unloaded += (sender, e) =>
105 this.ContextItemManager.Unsubscribe<ReadOnlyState>(this.OnReadOnlyStateChangedCallback);
108 DynamicArgumentWrapperObject.Editor = this;
111 ContextItemManager ContextItemManager
115 if (this.contextItemManager == null)
117 this.contextItemManager = this.OwnerActivity.GetEditingContext().Items;
119 return this.contextItemManager;
123 void OnReadOnlyStateChanged(ReadOnlyState state)
125 UpdateChildrenElementStatus();
128 void UpdateChildrenElementStatus()
130 this.isReadOnly = this.ContextItemManager.GetValue<ReadOnlyState>().IsReadOnly || this.DynamicArguments == null;
134 this.WPF_DataGrid.IsReadOnly = true;
135 this.ButtonMovDown.IsEnabled = false;
136 this.ButtonMovUp.IsEnabled = false;
137 this.ButtonDelete.IsEnabled = false;
141 void OnDataGridSelectionChanged(object sender, SelectionChangedEventArgs e)
144 || this.WPF_DataGrid.SelectedItems == null
145 || this.WPF_DataGrid.SelectedItems.Count == 0)
147 this.ButtonMovUp.IsEnabled = false;
148 this.ButtonMovDown.IsEnabled = false;
149 this.ButtonDelete.IsEnabled = false;
154 this.ButtonDelete.IsEnabled = true;
157 if (this.WPF_DataGrid.SelectedItems.Count == 1)
159 bool upHadFocus = ButtonMovUp.IsFocused;
160 bool downHadFocus = ButtonMovDown.IsFocused;
161 this.ButtonMovUp.IsEnabled = this.WPF_DataGrid.SelectedIndex > 0;
162 this.ButtonMovDown.IsEnabled = this.WPF_DataGrid.SelectedIndex < this.DynamicArguments.Count - 1;
163 if (!this.ButtonMovDown.IsEnabled && downHadFocus)
165 this.ButtonMovUp.Focus();
167 if (!this.ButtonMovUp.IsEnabled && upHadFocus)
169 this.ButtonMovDown.Focus();
174 this.ButtonMovUp.IsEnabled = this.ButtonMovDown.IsEnabled = false;
178 // The DataGrid does not bubble up KeyDown event and we expect the upper window to be closed when ESC key is down.
179 // Thus we added an event handler in DataGrid to handle ESC key and closes the uppper window.
180 void OnDataGridRowKeyDown(object sender, KeyEventArgs args)
182 DataGridRow row = (DataGridRow)sender;
183 if (args.Key == Key.Escape && !row.IsEditing && this.ParentDialog != null)
185 this.ParentDialog.CloseDialog(false);
189 protected override void OnInitialized(EventArgs e)
191 base.OnInitialized(e);
192 this.Unloaded += this.OnDynamicArgumentDesignerUnloaded;
195 SubscribeContextCallback<ReadOnlyState> OnReadOnlyStateChangedCallback
199 if (onReadOnlyStateChangedCallback == null)
201 onReadOnlyStateChangedCallback = new SubscribeContextCallback<ReadOnlyState>(OnReadOnlyStateChanged);
203 return onReadOnlyStateChangedCallback;
207 void OnDynamicArgumentDesignerUnloaded(object sender, RoutedEventArgs e)
209 this.WPF_DataGrid.LoadingRow -= this.DataGrid_Standard_LoadingRow;
210 this.Unloaded -= this.OnDynamicArgumentDesignerUnloaded;
213 public ObservableCollection<DynamicArgumentWrapperObject> DynamicArguments
217 return (ObservableCollection<DynamicArgumentWrapperObject>)GetValue(DynamicArgumentsProperty);
221 SetValue(DynamicArgumentsProperty, value);
224 this.WPF_DataGrid.ItemsSource = value;
229 [Fx.Tag.KnownXamlExternal]
230 public ModelItem OwnerActivity
232 get { return (ModelItem)GetValue(OwnerActivityProperty); }
233 set { SetValue(OwnerActivityProperty, value); }
236 [Fx.Tag.KnownXamlExternal]
237 public EditingContext Context
239 get { return (EditingContext)GetValue(ContextProperty); }
240 set { SetValue(ContextProperty, value); }
243 public bool IsDirectionReadOnly
245 get { return (bool)GetValue(IsDirectionReadOnlyProperty); }
246 set { SetValue(IsDirectionReadOnlyProperty, value); }
249 public bool HideDirection
253 return this.hideDirection;
257 this.hideDirection = value;
258 if (this.hideDirection)
260 this.WPF_DataGrid.Columns[DynamicArgumentDesigner.DirectionColumn].Visibility = Visibility.Hidden;
264 this.WPF_DataGrid.Columns[DynamicArgumentDesigner.DirectionColumn].Visibility = Visibility.Visible;
269 public string ArgumentPrefix
273 return this.argumentPrefix;
277 this.argumentPrefix = value;
281 public string HintText
285 if (this.hintText != null)
287 return this.hintText;
291 return (string)this.FindResource("addDynamicArgumentNewRowLabel");
296 this.hintText = value;
297 if (hintText == null)
299 dgHelper.AddNewRowContent = (string)this.FindResource("addDynamicArgumentNewRowLabel");
303 dgHelper.AddNewRowContent = hintText;
308 public WorkflowElementDialog ParentDialog
314 static void OnIsDirectionReadOnlyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
316 ((DynamicArgumentDesigner)dependencyObject).OnIsDirectionReadOnlyChanged();
319 void OnIsDirectionReadOnlyChanged()
321 if (!this.IsDirectionReadOnly)
323 DataGridTemplateColumn directionCol = this.WPF_DataGrid.Columns[1] as DataGridTemplateColumn;
324 directionCol.CellEditingTemplate = (DataTemplate)this.WPF_DataGrid.FindResource("argumentDirectionEditingTemplate");
328 internal Type UnderlyingArgumentType
332 return (Type)GetValue(UnderlyingArgumentTypeProperty);
336 if (!typeof(Argument).IsAssignableFrom(value))
338 ErrorReporting.ShowErrorMessage(SR.NonSupportedDynamicArgumentType);
342 SetValue(UnderlyingArgumentTypeProperty, value);
343 OnUnderlyingArgumentTypeChanged();
348 void OnUnderlyingArgumentTypeChanged()
350 Type currentArgumentType = this.UnderlyingArgumentType;
352 if (currentArgumentType != null && (OutArgumentType.IsAssignableFrom(currentArgumentType) || InOutArgumentType.IsAssignableFrom(currentArgumentType)))
354 this.WPF_DataGrid.Columns[DynamicArgumentDesigner.ExpressionColumn].Header = (string)this.FindResource("assignToHeader");
358 this.WPF_DataGrid.Columns[DynamicArgumentDesigner.ExpressionColumn].Header = (string)this.FindResource("valueHeader");
362 internal bool? IsDictionary
366 return (bool?)GetValue(IsDictionaryProperty);
370 SetValue(IsDictionaryProperty, value);
374 internal static ObservableCollection<DynamicArgumentWrapperObject> ModelItemToWrapperCollection(ModelItem model, out bool isDictionary, out Type underlyingArgumentType)
376 string errorMessage = string.Empty;
377 underlyingArgumentType = null;
378 isDictionary = false;
379 if (model is ModelItemCollection)
381 underlyingArgumentType = model.GetCurrentValue().GetType().GetGenericArguments()[0];
382 if (!typeof(Argument).IsAssignableFrom(underlyingArgumentType))
384 errorMessage = SR.NonSupportedDynamicArgumentType;
387 else if (model is ModelItemDictionary)
389 Type underlyingKeyType = model.GetCurrentValue().GetType().GetGenericArguments()[0];
390 underlyingArgumentType = model.GetCurrentValue().GetType().GetGenericArguments()[1];
391 if (!typeof(Argument).IsAssignableFrom(underlyingArgumentType))
393 errorMessage = SR.NonSupportedDynamicArgumentType;
395 if (underlyingKeyType != typeof(string))
397 errorMessage += SR.NonSupportedDynamicArgumentKeyType;
403 errorMessage = SR.NonSupportedModelItemCollectionOrDictionary;
405 if (!string.IsNullOrEmpty(errorMessage))
407 ErrorReporting.ShowErrorMessage(SR.NonSupportedModelItemCollectionOrDictionary);
412 ObservableCollection<DynamicArgumentWrapperObject> wrappers = new ObservableCollection<DynamicArgumentWrapperObject>();
413 foreach (ModelItem item in GetArgumentCollection(model))
415 wrappers.Add(new DynamicArgumentWrapperObject(item.Properties["Key"].ComputedValue as string, item.Properties["Value"].Value));
421 ObservableCollection<DynamicArgumentWrapperObject> wrappers = new ObservableCollection<DynamicArgumentWrapperObject>();
422 foreach (ModelItem item in GetArgumentCollection(model))
424 wrappers.Add(new DynamicArgumentWrapperObject(null, item));
430 internal static void WrapperCollectionToModelItem(ObservableCollection<DynamicArgumentWrapperObject> wrappers, ModelItem data, bool isDictionary, Type underlyingArgumentType)
432 ModelItemCollection collection = GetArgumentCollection(data);
433 using (ModelEditingScope change = collection.BeginEdit(SR.UpdateDynamicArgumentsDescription))
438 Type dictionaryEntryType = typeof(ModelItemKeyValuePair<,>).MakeGenericType(new Type[] { typeof(string), underlyingArgumentType });
439 foreach (DynamicArgumentWrapperObject wrapper in wrappers)
441 Argument argument = Argument.Create(wrapper.Type, wrapper.Direction);
442 object mutableKVPair = Activator.CreateInstance(dictionaryEntryType, new object[] { wrapper.Name, argument });
443 ModelItem argumentKVPair = collection.Add(mutableKVPair);
444 if (wrapper.Expression != null)
446 argumentKVPair.Properties["Value"].Value.Properties["Expression"].SetValue(wrapper.Expression.GetCurrentValue());
453 foreach (DynamicArgumentWrapperObject wrapper in wrappers)
455 Argument argument = Argument.Create(wrapper.Type, wrapper.Direction);
456 ModelItem argumentItem = collection.Add(argument);
457 if (wrapper.Expression != null)
459 argumentItem.Properties["Expression"].SetValue(wrapper.Expression.GetCurrentValue());
468 static ModelItemCollection GetArgumentCollection(ModelItem data)
470 if (data is ModelItemCollection)
472 return (data as ModelItemCollection);
474 else if (data is ModelItemDictionary)
476 return (data as ModelItemDictionary).Properties["ItemsCollection"].Collection;
480 ErrorReporting.ShowErrorMessage(SR.NonSupportedModelItemCollectionOrDictionary);
485 void OnDynamicArgumentsLoaded()
487 Fx.Assert(this.Context != null, "EditingContext cannot be null");
488 Fx.Assert(this.IsDictionary != null, "IsDictionary is not set");
489 Fx.Assert(this.UnderlyingArgumentType != null, "UnderlyingArgumentType is not set");
490 if (!(this.IsDictionary.Value))
492 this.WPF_DataGrid.Columns[DynamicArgumentDesigner.NameColumn].Visibility = Visibility.Hidden;
495 if (null != this.DynamicArguments)
497 if (this.UnderlyingArgumentType == ArgumentType)
499 this.IsDirectionReadOnly = false;
502 if (this.UnderlyingArgumentType.IsGenericType)
504 Type[] innerArgumentTypes = this.UnderlyingArgumentType.GetGenericArguments();
505 if (innerArgumentTypes.Length > 0)
507 Type innerArgumentType = innerArgumentTypes[0];
508 this.WPF_DataGrid.Columns[DynamicArgumentDesigner.ArgumentTypeColumn].IsReadOnly = !innerArgumentType.IsGenericParameter;
513 this.WPF_DataGrid.ItemsSource = this.DynamicArguments;
515 UpdateChildrenElementStatus();
518 internal void ValidateEntry(DynamicArgumentWrapperObject entry, DependencyPropertyChangedEventArgs e)
520 if (e.Property == DynamicArgumentWrapperObject.NameProperty)
522 if (this.IsDictionary.Value)
524 DataGridRow row = entry.Row;
525 string newName = e.NewValue as string;
528 this.DynamicArguments.Any<DynamicArgumentWrapperObject>(
529 p => string.Equals(p.Name, newName) && p != entry);
530 if (duplicates || string.IsNullOrEmpty(newName))
532 entry.Name = e.OldValue as string;
535 ErrorReporting.ShowErrorMessage(string.Format(CultureInfo.CurrentCulture, SR.DuplicateArgumentName, newName));
539 ErrorReporting.ShowErrorMessage(string.Format(CultureInfo.CurrentCulture, SR.EmptyArgumentName));
542 entry.IsValidating = false;
547 if (e.Property == DynamicArgumentWrapperObject.DirectionProperty)
549 entry.UseLocationExpression = (entry.Direction != ArgumentDirection.In);
551 if ((e.Property != DynamicArgumentWrapperObject.ExpressionProperty) && (entry.Expression != null))
553 ActivityWithResult expression = entry.Expression.GetCurrentValue() as ActivityWithResult;
554 if (expression != null)
556 ActivityWithResult newExpression;
557 if (ExpressionHelper.TryMorphExpression(expression, entry.UseLocationExpression, entry.Type, this.Context, out newExpression))
559 entry.Expression = (this.OwnerActivity as IModelTreeItem).ModelTreeManager.WrapAsModelItem(newExpression);
565 entry.Expression = null;
569 entry.IsValidating = false;
573 internal string GetDefaultName()
575 if (!this.IsDictionary.Value)
581 var defaultNames = this.DynamicArguments
582 .Select<DynamicArgumentWrapperObject, string>(p => (string)p.Name)
583 .Where<string>(p => 0 == string.Compare(p, 0, this.ArgumentPrefix, 0, this.ArgumentPrefix.Length, StringComparison.Ordinal))
584 .Select(p => p.Substring(this.ArgumentPrefix.Length));
587 foreach (string numberPart in defaultNames)
590 if (int.TryParse(numberPart, out current))
592 if (current >= maxNum)
594 maxNum = current + 1;
598 return string.Format(CultureInfo.InvariantCulture, "{0}{1}", this.ArgumentPrefix, maxNum);
603 internal Type GetDefaultType()
605 Type[] genericArguments = this.UnderlyingArgumentType.GetGenericArguments();
606 if (genericArguments.Length == 0)
608 return typeof(string);
612 return genericArguments[0];
616 internal ArgumentDirection GetDefaultDirection()
618 if (this.UnderlyingArgumentType == ArgumentType)
620 return ArgumentDirection.In;
623 if (InArgumentType.IsAssignableFrom(this.UnderlyingArgumentType))
625 return ArgumentDirection.In;
628 if (OutArgumentType.IsAssignableFrom(this.UnderlyingArgumentType))
630 return ArgumentDirection.Out;
633 Fx.Assert(InOutArgumentType.IsAssignableFrom(this.UnderlyingArgumentType), "UnderlyingArgumentType should be of type OutArgumentType");
634 return ArgumentDirection.InOut;
637 //Hook LoadingRow event to set different row template (<Click here to add new item>) for new place holder
638 void DataGrid_Standard_LoadingRow(object sender, DataGridRowEventArgs e)
640 if (e.Row.Item != CollectionView.NewItemPlaceholder)
642 DynamicArgumentWrapperObject wrapper = e.Row.Item as DynamicArgumentWrapperObject;
647 void OnCreateDynamicArgumentExecute(object sender, ExecutedRoutedEventArgs e)
649 DynamicArgumentWrapperObject wrapper = new DynamicArgumentWrapperObject();
650 this.DynamicArguments.Add(wrapper);
651 this.dgHelper.BeginRowEdit(wrapper);
654 void OnMoveUpArgumentExecute(object sender, RoutedEventArgs e)
656 if (null != this.WPF_DataGrid.SelectedItem)
658 int selectedArgumentIndex = this.WPF_DataGrid.SelectedIndex;
659 if (selectedArgumentIndex > 0)
661 this.DynamicArguments.Move(selectedArgumentIndex, selectedArgumentIndex - 1);
663 this.OnDataGridSelectionChanged(this, null);
667 void OnMoveDownArgumentExecute(object sender, RoutedEventArgs e)
669 if (null != this.WPF_DataGrid.SelectedItem)
671 int selectedArgumentIndex = this.WPF_DataGrid.SelectedIndex;
672 if (selectedArgumentIndex < this.DynamicArguments.Count - 1)
674 this.DynamicArguments.Move(selectedArgumentIndex, selectedArgumentIndex + 1);
676 this.OnDataGridSelectionChanged(this, null);
680 void OnDeleteArgumentExecute(object sender, RoutedEventArgs e)
682 DataGridHelper.OnDeleteSelectedItems(this.WPF_DataGrid);
685 void OnExpressionTextBoxLoaded(object sender, RoutedEventArgs args)
687 ExpressionTextBox etb = (ExpressionTextBox)sender;
688 etb.IsIndependentExpression = true;
691 DataGridHelper.OnEditingControlLoaded(sender, args);
695 void OnExpressionTextBoxUnloaded(object sender, RoutedEventArgs args)
697 ExpressionTextBox etb = (ExpressionTextBox)sender;
700 DataGridHelper.OnEditingControlUnloaded(sender, args);
704 void OnEditingControlLoaded(object sender, RoutedEventArgs args)
706 DataGridHelper.OnEditingControlLoaded(sender, args);
709 void OnEditingControlUnloaded(object sender, RoutedEventArgs args)
711 DataGridHelper.OnEditingControlUnloaded(sender, args);
715 sealed class DynamicArgumentWrapperObject : DependencyObject
717 public static readonly DependencyProperty ModelItemProperty = DependencyProperty.Register(
720 typeof(DynamicArgumentWrapperObject),
721 new UIPropertyMetadata(null));
723 public static readonly DependencyProperty NameProperty = DependencyProperty.Register(
726 typeof(DynamicArgumentWrapperObject),
727 new UIPropertyMetadata(string.Empty, OnArgumentPropertyChanged));
729 public static readonly DependencyProperty ArgumentTypeProperty = DependencyProperty.Register(
732 typeof(DynamicArgumentWrapperObject),
733 new UIPropertyMetadata(typeof(string), OnArgumentPropertyChanged));
735 public static readonly DependencyProperty DirectionProperty = DependencyProperty.Register(
737 typeof(ArgumentDirection),
738 typeof(DynamicArgumentWrapperObject),
739 new UIPropertyMetadata(ArgumentDirection.In, OnArgumentPropertyChanged));
741 public static readonly DependencyProperty ExpressionProperty =
742 DependencyProperty.Register(
745 typeof(DynamicArgumentWrapperObject),
746 new UIPropertyMetadata(OnArgumentPropertyChanged));
748 public static readonly DependencyProperty UseLocationExpressionProperty =
749 DependencyProperty.Register(
750 "UseLocationExpression",
752 typeof(DynamicArgumentWrapperObject));
754 public event PropertyChangedEventHandler PropertyChanged;
758 const string ExpressionPropertyName = "Expression";
762 get { return (string)GetValue(NameProperty); }
763 set { SetValue(NameProperty, value); }
768 get { return (Type)GetValue(ArgumentTypeProperty); }
769 set { SetValue(ArgumentTypeProperty, value); }
772 public ArgumentDirection Direction
774 get { return (ArgumentDirection)GetValue(DirectionProperty); }
775 set { SetValue(DirectionProperty, value); }
778 public ModelItem Expression
780 get { return (ModelItem)GetValue(ExpressionProperty); }
781 set { SetValue(ExpressionProperty, value); }
784 public bool UseLocationExpression
786 get { return (bool)GetValue(UseLocationExpressionProperty); }
787 set { SetValue(UseLocationExpressionProperty, value); }
790 internal bool IsValidating
796 internal DataGridRow Row
802 public static DynamicArgumentDesigner Editor
808 public DynamicArgumentWrapperObject()
810 this.isInitializing = true;
811 this.IsValidating = false;
812 this.Name = DynamicArgumentWrapperObject.Editor.GetDefaultName();
813 this.Type = DynamicArgumentWrapperObject.Editor.GetDefaultType();
814 this.Direction = DynamicArgumentWrapperObject.Editor.GetDefaultDirection();
815 this.UseLocationExpression = (this.Direction != ArgumentDirection.In);
816 this.isInitializing = false;
819 public DynamicArgumentWrapperObject(string argumentName, ModelItem argumentItem)
821 Fx.Assert(argumentItem != null, "argumentItem canot be null");
822 this.isInitializing = true;
823 this.IsValidating = false;
824 Argument argument = (Argument)argumentItem.GetCurrentValue();
825 this.Name = argumentName;
826 this.Direction = argument.Direction;
827 this.UseLocationExpression = (this.Direction != ArgumentDirection.In);
828 this.Type = argument.ArgumentType;
829 this.Expression = argumentItem.Properties[ExpressionPropertyName].Value;
830 this.isInitializing = false;
833 static void OnArgumentPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
835 DynamicArgumentWrapperObject wrapper = (DynamicArgumentWrapperObject)sender;
836 if (!wrapper.IsValidating && !wrapper.isInitializing)
838 wrapper.OnArgumentPropertyChanged(e);
842 void OnArgumentPropertyChanged(DependencyPropertyChangedEventArgs e)
844 Fx.Assert(DynamicArgumentWrapperObject.Editor != null, "collection editor is null!");
845 this.IsValidating = true;
846 DynamicArgumentWrapperObject.Editor.ValidateEntry(this, e);
848 if (this.PropertyChanged != null)
850 this.PropertyChanged(this, new PropertyChangedEventArgs(e.Property.Name));
854 // For screen reader to read the DataGrid row.
855 public override string ToString()
857 return string.IsNullOrEmpty(this.Name) ? "Parameter" : this.Name;