public void RegisterDialog <TModel, TDialog>() where TModel : ModalDialogBase where TDialog : Window { InteropCommandService.LogStack(); var modelType = typeof(TModel); if (!_registeredModelDialogCache.ContainsKey(modelType)) { _registeredModelDialogCache[modelType] = typeof(TDialog); return; } throw new InvalidOperationException(Strings.exceptionDialogAlreadyRegistered); }
public bool?ShowDialog <TModel>(TModel modalDialogModel) where TModel : ModalDialogBase { InteropCommandService.LogStack(); if (!_registeredModelDialogCache.ContainsKey(typeof(TModel))) { throw new InvalidOperationException(Strings.exceptionDialogForModelNotRegistered); } var dialogType = _registeredModelDialogCache[typeof(TModel)]; var dialog = CreateDialog(dialogType); dialog.DataContext = modalDialogModel; dialog.Owner = _dialogsOwner; return(dialog.ShowDialog()); }
private Window CreateDialog(Type dialogType) { InteropCommandService.LogStack(); if (dialogType == null) { throw new ArgumentNullException(dialogType.Name); } var instance = Activator.CreateInstance(dialogType); var dialog = instance as Window; if (dialog != null) { return(dialog); } throw new ArgumentException(Strings.exceptionDialogNotSupported + dialogType.Name); }
public void SetDialogsOwner(Window dialogsOwner) { InteropCommandService.LogStack(); _dialogsOwner = dialogsOwner; }