class ImportMatFileCommand : ViewModelBase, ICommand { #region Members private ImportFileViewModel materialFile; private ObservableCollection<ImportErrorViewModel> errors = new ObservableCollection<ImportErrorViewModel>(); private Int32 numberOfLines = 1; private Int32 processedLines = 0; #endregion #region ICommand Members /// <summary> /// Whether the ShowModuleAViewCommand is enabled. ///</summary> public bool CanExecute(object param) { //canexecute } /// <summary> /// Actions to take when CanExecute() changes. /// </summary> public event EventHandler CanExecuteChanged { add { CommandManager.RequerySuggested += value; } remove { CommandManager.RequerySuggested -= value; } } /// <summary> /// Executes the ShowModuleAViewCommand /// </summary> public async void Execute(object param) { await ImportAsync(); } #endregion #region Properties public ImportFileViewModel MaterialFile { get { return materialFile; } set { materialFile = value; base.RaisePropertyChangedEvent("MaterialFile"); } } public ObservableCollection<ImportErrorViewModel> Errors { get { return errors; } set { errors = value; base.RaisePropertyChangedEvent("Errors"); } } public Int32 NumberOfLines { get { return numberOfLines; } set { numberOfLines = value; base.RaisePropertyChangedEvent("NumberOfLines"); } } public Int32 ProcessedLines { get { return processedLines; } set { processedLines = value; base.RaisePropertyChangedEvent("ProcessedLines"); } } #endregion #region Private Methods private Task ImportAsync() { return Task.Run(() => Import()); } private void Import() { //long running process.... } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)