Navigation

You can navigate between pages (i.e. between root components) using the following extensions API:

INavigation.PushAsync<T>()

where T is the type of the component to create as root of the new page.

For example this is a component that move to second page hosting ChildPageComponent when user click a button:

public class MainPageComponent : RxComponent
{
    public override VisualNode Render()
    {
        return new RxNavigationPage()
        {
            new RxContentPage()
            {
                new RxButton("Move To Page")
                    .VCenter()
                    .HCenter()
                    .OnClick(OpenChildPage)
            }
            .Title("Main Page")
        };
    }

    private async void OpenChildPage()
    {
        await Navigation.PushAsync<ChildPageComponent>();
    }
}

and this is the code implementing the child page with a button to go back

Passing data between pages

You can pass parameters to other pages using component Props. Let's modify the main page component from the above sample to hold a state:

In the OpenChildPage callback we need to open the child page passing current value: we want to edit the value in entry control. Let's change the child page adding a state and a props as the following:

Now the ChildPageComponent has a state and a props: the latter will hold the initial value and a callback action to call when user click the back button.

Finally call the child page setting its props properties:

Passing data between pages

Last updated

Was this helpful?