Prism Sample 19-NavigationParticipation

Navigation Participation,不知翻译方法,意思是对导航过程的参与,触发事件,类似离开导航目标和进入导航的回调

在VM中,增加一个接口 ,然后实现导航事件

public class ViewAViewModel : BindableBase, INavigationAware
    {
      ……

        private int _pageViews;
        public int PageViews
        {
            get { return _pageViews; }
            set { SetProperty(ref _pageViews, value); }
        }

        public ViewAViewModel()
        {

        }

        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            PageViews++;
        }

        public bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true;
        }

        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
            
        }
    }

 

posted @ 2021-06-16 11:04  cbaa  阅读(118)  评论(0编辑  收藏  举报