public NavigationRoot(IDetailNavigation detailNavigation, IViewFor <NavigationMenuViewModel> menuPage) { InitializeComponent(); NavigationPage.SetHasNavigationBar(this, false); detailNavigation.PushPage <MainViewModel>(resetStack: true, animate: false).Subscribe(); Detail = (NavigationView)detailNavigation.View; Master = (ContentPage)menuPage; menuPage .WhenAnyObservable(x => x.ViewModel.Navigate) .Select(_ => false) .BindTo(this, x => x.IsPresented); Events .DeviceDisplayMainDisplayInfoChanged .Where(x => x.DisplayInfo.Orientation == DisplayOrientation.Landscape && Device.Idiom == TargetIdiom.Tablet) .Subscribe(x => MasterBehavior = MasterBehavior.SplitOnLandscape) .DisposeWith(_masterDetailBindings); // HACK: [rlittlesii: July 04, 2020] This is a hack around a Xamarin.Forms iOS issue. this.WhenAnyValue(x => x.IsPresented) .Where(x => Device.RuntimePlatform == Device.iOS) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(_ => Master.IconImageSource = ImageSource.FromFile("hamburger.png")) .DisposeWith(_masterDetailBindings); ViewModel = new NavigationRootViewModel(); }
public NavigationMenuViewModel(IDetailNavigation detailNavigation) { _detailNavigation = detailNavigation; Items = new ReadOnlyObservableCollection <NavigationItemViewModel>( new ObservableCollection <NavigationItemViewModel> { new NavigationItemViewModel { Title = "List View", Icon = ListAlt, IViewFor = typeof(ListOptionsViewModel) }, new NavigationItemViewModel { Title = "Collection View", Icon = LayerGroup, IViewFor = typeof(CollectionOptionsViewModel) } }); Navigate = ReactiveCommand.CreateFromObservable <NavigationItemViewModel, Unit>(ExecuteNavigate); }
public ListOptionsViewModel() { _detailNavigation = Locator.Current.GetService <IDetailNavigation>(); Navigate = ReactiveCommand.CreateFromObservable <OptionViewModel, Unit>(ExecuteNavigate); Items = new ObservableCollection <OptionViewModel> { new OptionViewModel { Option = ListOption.DetailNavigation }, new OptionViewModel { Option = ListOption.Search }, new OptionViewModel { Option = ListOption.InfiniteScroll } }; }