示例#1
0
        protected override void OnInitialize()
        {
            DisplayName = Strings.ImportViewModel_DisplayName;

            OkCmd     = new AsyncCommand(Ok);
            CancelCmd = new RelayCommand(Cancel);


            var loaderTask = Task.Run(async delegate
            {
                var customization = await _productServiceModel.GetCustomization().ConfigureAwait(false);
                await Execute.OnUIThreadAsync(delegate
                {
                    var importers = customization.Importers.Select(i => new ImporterViewModel(i, _productServiceModel));
                    Importers     = new BindableCollection <ImporterViewModel>(importers);

                    if (Importers.Count > 0)
                    {
                        SelectedImporter = Importers[0];
                    }
                });
            });

            TaskNotifier = new TaskNotifier(loaderTask);
        }
        protected override void OnInitialize()
        {
            base.OnInitialize();

            var loadingTask = Task.Run(async delegate
            {
                try
                {
                    var customization = await _productServiceModel.GetCustomization().ConfigureAwait(false);
                    await Execute.OnUIThreadAsync(delegate
                    {
                        PossibleRecipeTypes      = customization.RecipeTypes.Select(r => new RecipeDefinitionViewModel(r)).ToArray();
                        SelectedRecipeDefinition = PossibleRecipeTypes.FirstOrDefault();
                    });
                }
                catch (Exception e)
                {
                    await Execute.OnUIThreadAsync(() => ErrorMessage = e.Message);
                }
            });

            TaskNotifier = new TaskNotifier(loadingTask);
        }