public static object RequestInput <T>(INotifyPropertyChanged parent, IDialogService dialogService, string displayName, string text, T value, Func <T, bool> validate) { IInputViewModel InputForm = ViewModelLocator.Instance.Input; // How to manage class instance? For now it's always using the same ViewModel isntance so reset it. (InputForm as InputViewModel).DialogResult = null; InputForm.DisplayName = displayName; InputForm.Text = text; InputForm.Value = value.ToString(); InputForm.Validate = new Func <string, bool>((e) => { try { T Val = ChangeType <T>(e, null); return(validate(Val)); } catch { return(false); } }); if (dialogService.ShowDialog(parent, InputForm) == true) { try { return(ChangeType <T>(InputForm.Value, null)); } catch { return(null); } } else { return(null); } }
public SearchViewModel(IInputViewModel inputViewModel, ISearchModeViewModel searchModeViewModel, ISearchQueriesViewModel searchQueriesViewModel) { if (inputViewModel == null) { throw new ArgumentNullException(nameof(inputViewModel)); } if (searchModeViewModel == null) { throw new ArgumentNullException(nameof(searchModeViewModel)); } if (searchQueriesViewModel == null) { throw new ArgumentNullException(nameof(searchQueriesViewModel)); } InputViewModel = inputViewModel; SearchModeViewModel = searchModeViewModel; SearchQueriesViewModel = searchQueriesViewModel; }
public ShellViewModel(IPrimesViewModel primesViewModel, IInputViewModel inputViewModel) { PrimesViewModel = primesViewModel; InputViewModel = inputViewModel; }