Exemple #1
0
        public async Task <TViewModel> ShowDialogAsync <TView, TViewModel>(string title, object?parameter = null) where TView : UserControl
            where TViewModel : class, IDialogViewModel <TViewModel>
        {
            var window = await windowService.GetCurrentWindowWithViewModelAsync();

            IMainWindowViewModel?vm = window.DataContext as IMainWindowViewModel;

            if (vm != null)
            {
                vm.Dialog = new DialogModel <TViewModel>(iocService.ResolveTemporaryType <TView>(), iocService.ResolveTemporaryType <TViewModel>(parameter), title);

                vm.Dialog.ViewModel.MainViewModelCloseAction = () =>
                {
                    vm.Dialog = null;
                };
                return(await((IDialogViewModel <TViewModel>)((DialogModel <TViewModel>)vm.Dialog).ViewModel).WaitForButonTask());
            }

            return(iocService.ResolveTemporaryType <TViewModel>(parameter));
        }
        public void NavigateTo <TViewModel, TView>(object?parameter = null) where TViewModel : class, IViewModel where TView : class
        {
            if (NavigationViewModel?.Current?.ViewModel.GetType() == typeof(TViewModel) && NavigationViewModel.Current?.View.GetType() == typeof(TView) && NavigationViewModel.Current?.ViewModel.IsSingleInstance == true)
            {
                return;
            }

            var view      = iocService.ResolveTemporaryType <TView>(parameter) as FrameworkElement;
            var viewModel = iocService.ResolveTemporaryType <TViewModel>(parameter) as IViewModel;

            if (view != null)
            {
                view.DataContext = viewModel;
                var item = new NavigationItem(view, viewModel);

                if (NavigationViewModel?.Current != null)
                {
                    stack.Push(NavigationViewModel.Current);
                    NavigationViewModel.AddBreadCrumb(NavigationViewModel.Current);
                }
                NavigationViewModel?.SetCurrent(item);
            }
        }
Exemple #3
0
 public ESPControllerViewModel(ESPEcho esp, IIoCService ioc)
 {
     Name       = "Controller for " + esp.Name;
     SettingsVM = ioc.ResolveTemporaryType <SettingsViewModel>(esp);
 }