private void SubscribeToViewModelEvents(ProjectsViewModel projectsViewModel) { if (projectsViewModel.Projects.Count > 0) { AddProjectsItems(projectsViewModel.Projects.ToList() as IList <Project>); } projectsViewModel.Projects.CollectionChanged += OnProjectsCollectionChanged; projectsViewModel.ProjectSelected += OnProjectSelected; }
private void DataContextChangedEventHandler(object sender, DependencyPropertyChangedEventArgs e) { if (DataContext != null && DataContext is ProjectsViewModel) { _viewModel = DataContext as ProjectsViewModel; Control createProjectControl = CreateCpControl(); currentUserProjectsContainer.Children.Add(createProjectControl); _viewModel.ViewContext = this; SubscribeToViewModelEvents(); RefreshShowErrorMessageDialogVisibility(); RefreshCreateNewProjectDialogVisibility(); } }
public ProjectsView() { InitializeComponent(); if (DataContext is ProjectsViewModel) { _viewModel = DataContext as ProjectsViewModel; Control createProjectControl = CreateCpControl(); currentUserProjectsContainer.Children.Add(createProjectControl); SubscribeToViewModelEvents(); RefreshShowErrorMessageDialogVisibility(); RefreshCreateNewProjectDialogVisibility(); } else { DataContextChanged += new DependencyPropertyChangedEventHandler(DataContextChangedEventHandler); } }