KAMISHIBAI for Xamarin.Forms is Page navigation library that supports MVVM patterns.
KAMISHIBAI will grant the following features to Xamarin.Forms.
- Consistent event notification on Page navigation
- Generic Type Parameters on Page navigation
- Compatibility of MVVM Pattern and direct manipulation feeling against INavigation
And KAMISHIBAI does not limit Xamarin.Forms. All possible Navigation in Xamarin.Forms is also possible in KAMISHIBAI.
The feature of KAMISHIBAI's Navigation Service is that it is not a monolithic structure. Navigation is separated into two roles.
- Send Page navigation request from View Model to View
- Based on Page navigation request, navigation Page on the View layer
Please see specific examples.
Use INavigationRequest to make Page navigation request.
When executing Command, it is sending RequestSecondPage request.
public ICommand NavigateCommand => new Command(() => RequestSecondPage.RaiseAsync());
public INavigationRequest RequestSecondPage { get; } = new NavigationRequest();<?xml version="1.0" encoding="utf-8" ?>
<ContentPage ...>
<ContentPage.Behaviors>
<mvvm:PushModalAsync Request="{Binding RequestSecondPage}" x:TypeArguments="views:SecondPage"/>
</ContentPage.Behaviors>
<StackLayout>
<Button Text="Navigate to Second" Command="{Binding NavigateCommand}"/>
</StackLayout>
</ContentPage>Notice the PushModalAsync Behavior.
<mvvm:PushModalAsync Request="{Binding RequestSecondPage}" x:TypeArguments="views:SecondPage"/>Based on RequestSecondPage Navigation request, it is defined to make a Modal Navigation to SecondPage.
PushModalAsync navigation Page with Kamisibai.Xamarin.Forms.Navigator.
Navigator wraps Xamarin.Forms.INavigation and adds navigation parameter and navigation event to INavigation.
Using KAMISHIBAI, you can receive events with consistency and recursion.
Look at the following code.
var masterDetailPage = new MasterDetailPage();
masterDetailPage.Master = new ContentPage {Title = "Master"};
var tabbedPage = new TabbedPage();
tabbedPage.Children.Add(new NavigationPage(new ContentPage()){ Title = "Tab 1"});
tabbedPage.Children.Add(new NavigationPage(new ContentPage()){ Title = "Tab 2"});
tabbedPage.Children.Add(new NavigationPage(new ContentPage()){ Title = "Tab 3"});
navigator.PushModalAsync(masterDetailPage);Events can be received on all pages of transition source and destination.
The number of Page to navigation to... 9?
Perhaps I will make a mistake. But KAMISHIBAI makes no mistake.
KAMISHIBAI, pass the parameters on navigation easily and safely.
An example of passing a DateTime as a parameter.
public INavigationRequest<DateTime> RequestSecondPage { get; } = new NavigationRequest<DateTime>();
public Task Navigate(DateTime selectedDate)
{
return RequestSecondPage.RaiseAsync(selectedDate);
}And receive the following.
Implement IPageInitializeAware and receive it with OnInitialize method.
public class SecondPageViewModel : IPageInitializeAware<DateTime>, INotifyPropertyChanged
{
...
public void OnInitialize(DateTime selectedDate)
{
SelectedDate = selectedDate;
}Were you interested in KAMISHIBAI?
KAMISHIBAI offers the following content to support you.
Let's use Xamarin.Forms with the most flexible Page navigation library!
Install from NuGet.
> Install-Package Kamishibai.Xamarin.Forms