public void PropertiesWithNotification() { INewItemsView view = Container.GetExportedValue <INewItemsView>(); NewItemsViewModel viewModel = Container.GetExportedValue <NewItemsViewModel>(); object mockView1 = new object(); AssertHelper.PropertyChangedEvent(viewModel, x => x.ActiveNewItemView, () => viewModel.ActiveNewItemView = mockView1); Assert.AreEqual(mockView1, viewModel.ActiveNewItemView); ICommand addItemCommand = new DelegateCommand(() => { }); AssertHelper.PropertyChangedEvent(viewModel, x => x.AddItemCommand, () => viewModel.AddItemCommand = addItemCommand); Assert.AreEqual(addItemCommand, viewModel.AddItemCommand); bool resetCountDownData = viewModel.ResetCountDownData; AssertHelper.PropertyChangedEvent(viewModel, x => x.ResetCountDownData, () => viewModel.ResetCountDownData = !resetCountDownData); Assert.AreEqual(!resetCountDownData, viewModel.ResetCountDownData); int alertBeforeMinutes = viewModel.AlertBeforeMinutes; AssertHelper.PropertyChangedEvent(viewModel, x => x.AlertBeforeMinutes, () => viewModel.AlertBeforeMinutes = alertBeforeMinutes + 5); Assert.AreEqual(alertBeforeMinutes + 5, viewModel.AlertBeforeMinutes); }
public ApplicationController(CompositionContainer container, IPresentationService presentationService, ShellService shellService, DataController dataController, NewItemsController newItemsController) { InitializeCultures(); presentationService.InitializeCultures(); this.container = container; this.dataController = dataController; this.newItemsController = newItemsController; this.shellViewModel = container.GetExportedValue <ShellViewModel>(); this.itemListViewModel = container.GetExportedValue <ItemListViewModel>(); this.newItemsViewModel = container.GetExportedValue <NewItemsViewModel>(); shellService.ShellView = shellViewModel.View; shellService.ItemListView = itemListViewModel.View; shellService.NewItemsView = newItemsViewModel.View; this.shellViewModel.Closing += ShellViewModelClosing; this.exitCommand = new DelegateCommand(Close); this.settingCommand = new DelegateCommand(SettingDialogCommand); this.aboutCommand = new DelegateCommand(AboutDialogCommand); }
protected override void OnInitialize() { this.newItemsViewModel = container.GetExportedValue <NewItemsViewModel>(); AddWeakEventListener(this.newItemsViewModel, NewItemsViewModelPropertyChanged); IAlertAtTimeView alertAtTimeView = this.container.GetExportedValue <IAlertAtTimeView>(); AlertAtTimeViewModel alertAtTimeViewModel = new AlertAtTimeViewModel(alertAtTimeView, this.dataService); alertAtTimeView.Title = alertAtTimeViewModel.Title; this.newItemsViewModel.NewItemViews.Add(alertAtTimeView); this.viewDictionary.Add(alertAtTimeView, alertAtTimeViewModel.NewItem); ICountDownAlertView countDownAlertView = this.container.GetExportedValue <ICountDownAlertView>(); CountDownAlertViewModel countDownAlertViewModel = new CountDownAlertViewModel(countDownAlertView, this.dataService); countDownAlertView.Title = countDownAlertViewModel.Title; this.newItemsViewModel.NewItemViews.Add(countDownAlertView); this.viewDictionary.Add(countDownAlertView, countDownAlertViewModel.NewItem); this.newItemsViewModel.AddItemCommand = this.addItemCommand; if (string.IsNullOrEmpty(Settings.Default.SelectNewItem)) { this.newItemsViewModel.ActiveNewItemView = this.newItemsViewModel.NewItemViews.First(); } else { foreach (object view in this.newItemsViewModel.NewItemViews) { INewItemViewModel viewModel = ViewHelper.GetViewModel(view as IView) as INewItemViewModel; if (viewModel.Title == Settings.Default.SelectNewItem) { this.newItemsViewModel.ActiveNewItemView = view; } } } }
public NewItemPage() { InitializeComponent(); BindingContext = _viewModel = AppLocator.NewItemsViewModel; }
public NewItemPage() { InitializeComponent(); BindingContext = viewModel = new NewItemsViewModel();; }