Exemple #1
0
        /// <summary>
        /// Code to execute when a SharePoint View has been loaded completely.
        /// </summary>
        /// <param name="e" />
        private void OnLoadViewDataCompleted(LoadViewCompletedEventArgs e)
        {
            IsBusy = false;
            if (e.Error != null)
            {
                OnViewDataLoaded(this, new ViewDataLoadedEventArgs {
                    ViewName = e.ViewName, Error = e.Error
                });
                return;
            }

            //Create a collection of DisplayItemViewModels
            ObservableCollection <DisplayItemViewModel> displayViewModelCollection = new ObservableCollection <DisplayItemViewModel>();

            foreach (ListItem item in e.Items)
            {
                DisplayItemViewModel displayViewModel = new DisplayItemViewModel {
                    ID = item.Id.ToString(), DataProvider = this.DataProvider
                };
                displayViewModel.Initialize();

                displayViewModelCollection.Add(displayViewModel);
            }

            OnViewDataLoaded(this, new ViewDataLoadedEventArgs {
                ViewName = e.ViewName, ViewData = displayViewModelCollection
            });
        }
        /// <summary>
        /// Code to execute when app navigates to Display Form
        /// </summary>
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            viewModel = App.MainViewModel.SelectedItemDisplayViewModelInstance;
            viewModel.InitializationCompleted += new EventHandler <InitializationCompletedEventArgs>(OnViewModelInitialization);
            if (!viewModel.IsInitialized)
            {
                viewModel.Initialize();
            }

            this.DataContext = viewModel;
        }