I am currently working in a Xamarin Forms project and am attempting to use ReactiveUI with a Master Detail Page navigation standard Xamarin Forms project.
After reading through the documentation on the ReactiveUI website as well as the book 'You, I and ReactiveUI' by Kent Boogaart I am still lost on how to make a Master Detail setup work with ReactiveUI and Xamarin Forms for app navigation.
I have the app being bootstrapped, which loads the root view (Master Detail Page):
internal sealed class AppBootstrap: ReactiveObject, IScreen
{
public AppBootstrap()
{
RegisterDependencies();
this
.Router
.NavigateAndReset
.Execute(GetRootViewModel())
.Subscribe();
}
public RoutingState Router { get; } = new RoutingState();
public Page GetMainPage() => new RoutedViewHost();
private void RegisterDependencies()
{
Locator.CurrentMutable.RegisterConstant(this, typeof(IScreen));
/*View Model Registrations*/
Locator.CurrentMutable.Register(() => new RootView(), typeof(IViewFor<RootViewModel>));
Locator.CurrentMutable.Register(()=> new MenuView(), typeof(IViewFor<MenuViewModel>));
Locator.CurrentMutable.Register(()=> new DetailView(), typeof(IViewFor<DetailViewModel>));
/*Service Registrations*/
}
private IRoutableViewModel GetRootViewModel()
{
//Add check for login here
return new RootViewModel(this);
}
}
And then in my RootViewModel:
public sealed class RootViewModel: ViewModelBase
{
private Page _masterPage;
private Page _detailPage;
public RootViewModel(IScreen hostScreen) : base(hostScreen)
{ }
public Page MasterPage
{
get => _masterPage;
set => this.RaiseAndSetIfChanged(ref _masterPage, value);
}
public Page DetailPage
{
get => _detailPage;
set => this.RaiseAndSetIfChanged(ref _detailPage, value);
}
public override Action<CompositeDisposable> OnActivated()
{
//What do I do?
}
}
After googling and searching stack overflow there appears to be no answer here and the 'documentation' isn't too helpful. Both the samples listed on the ReactiveUI site as well as all the blog posts online only deal with single page navigation; vice the more standard drawer based navigation that most real world phone applications implement.
Any help on what to do or links to actual working Master Detail Page based navigation would be extremely helpful as I have just failed on my attempts to find anything of substance.