public MultipleValuedDataModelPropertyViewModel(Func <TPropertyType> appendValue, Action <int> elementRemovedAt, IEnumerable <TPropertyType> values, string caption) { _appendValue = appendValue; _elementRemovedAt = elementRemovedAt; _values = new ObservableCollection <TPropertyType>(values ?? new TPropertyType[0]); Values = new ReadOnlyObservableCollection <TPropertyType>(_values); AddElementCommand = new CommandViewModel(OnAddElementCommand, "Add"); RemoveElementAtCommand = new CommandViewModel(OnRemoveElementAtCommand, "Remove"); Caption = caption; }
public TreeElementViewModel(ApplicationViewModel application, string name, TreeElementType? treeElementType = null) { _application = application; Name = name; Type = treeElementType.GetValueOrDefault(GuessElementTypeByFileExtension(name)); _children = new ObservableCollection<TreeElementViewModel>(); Children = new ReadOnlyObservableCollection<TreeElementViewModel>(_children); _commands = new ObservableCollection<CommandViewModel>(); Commands = new ReadOnlyObservableCollection<CommandViewModel>(_commands); if (treeElementType.GetValueOrDefault(TreeElementType.Folder) != TreeElementType.Folder) { DefaultActionCommand = new CommandViewModel(OnDefaultActionCommand, "Open"); _commands.Add(DefaultActionCommand); } }
public TreeElementViewModel(ApplicationViewModel application, string name, TreeElementType?treeElementType = null) { _application = application; Name = name; Type = treeElementType.GetValueOrDefault(GuessElementTypeByFileExtension(name)); _children = new ObservableCollection <TreeElementViewModel>(); Children = new ReadOnlyObservableCollection <TreeElementViewModel>(_children); _commands = new ObservableCollection <CommandViewModel>(); Commands = new ReadOnlyObservableCollection <CommandViewModel>(_commands); if (treeElementType.GetValueOrDefault(TreeElementType.Folder) != TreeElementType.Folder) { DefaultActionCommand = new CommandViewModel(OnDefaultActionCommand, "Open"); _commands.Add(DefaultActionCommand); } }
public void AddCommand(CommandViewModel command) { _commands.Add(command); }