/// <summary>
        /// Set the Detail, hide the menu and make sure, that the correct menu entry is selected.
        /// </summary>
        /// <param name="page">The new detail.</param>
        /// <param name="pageData">The detail data associated with the new page, provide if already known. Will get resolved otherwise.</param>
        internal void SetDetail(Page page, MvvmNanoMasterDetailData pageData = null)
        {
            var oldDetailData = _currentDetailData;

            //Resolve the page data if it is not given
            if (pageData == null)
            {
                pageData = MasterDetails.FirstOrDefault(
                    x => ViewViewModelHelper.ViewNameFromViewModel(x.ViewModelType) == page.GetType().Name);

                if (pageData == null)
                {
                    throw new MvvmNanoException($"There is no detail registered for the page ${page.GetType().Name}.");
                }
            }

            _currentDetailData = pageData;

            //Set the title if the page does not have one
            if (string.IsNullOrEmpty(page.Title))
            {
                page.Title = pageData.Title;
            }

            //Show the page if it is not already presented
            if (_detail != page)
            {
                _detail     = page;
                Detail      = new MvvmNanoNavigationPage(page);
                IsPresented = false;
            }

            DetailSet(oldDetailData, pageData, page);
        }
예제 #2
0
 protected override void DetailSet(MvvmNanoMasterDetailData lastDetailData, MvvmNanoMasterDetailData newDetailData, Page page)
 {
     //Highlight the new page
     if (DetailListView.SelectedItem == null || //No page was selected
         lastDetailData != newDetailData)       //A page with a different name is selected
     {
         DetailListView.SelectedItem = newDetailData;
     }
 }
        protected void AddDetailData <TViewModel>(MvvmNanoMasterDetailData data) where TViewModel : MvvmNanoViewModel
        {
            data.ViewModelType = typeof(TViewModel);
            data.ViewModelType = data.ViewModelType;
            MasterDetails.Add(data);

            DetailDataAdded <TViewModel>(data);

            //Check if this is the first window, show it if that is the case.
            if (MasterDetails.Count == 1)
            {
                SetDetail(data);
            }
        }
 /// <summary>
 /// Called when a new detail data item is added. Detail data is already added to <see cref="MasterDetails"/> at this point.
 /// </summary>
 /// <param name="detailData">The added detail data.</param>
 protected virtual void DetailDataAdded <TViewModel>(MvvmNanoMasterDetailData detailData)
 {
 }
        /// <summary>
        /// Opens the page a <see cref="MvvmNanoMasterDetailData.ViewModelType"/> is referencing to.
        /// </summary>
        /// <param name="data"></param>
        public void SetDetail(MvvmNanoMasterDetailData data)
        {
            var page = CreatePage(data.ViewModelType);

            SetDetail(page, data);
        }
 /// <summary>
 /// Called when a new detail data is set as detail page.
 /// </summary>
 /// <param name="lastDetailData">The detail data that was set bevore. Can be null if this is the first time a detail is set.</param>
 /// <param name="newDetailData">The new detail that is set.</param>
 /// <param name="page">The page represented by the detail data that is shown now.</param>
 protected virtual void DetailSet(MvvmNanoMasterDetailData lastDetailData, MvvmNanoMasterDetailData newDetailData, Page page)
 {
 }