Skip to content

How to switch to another page by clicking a button in Avalonia Community.Toolkit? #14634

Answered by thevortexcloud
Zakarayaev asked this question in Q&A
Discussion options

You must be logged in to vote

You can technically do it without a "router" (EG directly setting the active VM everywhere you need it) but it can quickly get fairly messy. It's just a way to manage all your views/VMs and navigate between them. I will show you some sample code from my custom router to help explain:

In the below XAML my active page is bound to the content control. When one of the buttons is pressed, the CurrentPage property is updated to match what ever VM is mapped to value the button passed to my router.

        <Grid ColumnDefinitions="auto *">
            <StackPanel Orientation="Vertical" Margin="10">
                <StackPanel.Styles>
                    <Style Selector="Button">
                 …

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
2 replies
@jaskij
Comment options

@thevortexcloud
Comment options

Comment options

You must be logged in to vote
4 replies
@Zakarayaev
Comment options

@thevortexcloud
Comment options

@Zakarayaev
Comment options

@thevortexcloud
Comment options

Answer selected by Zakarayaev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants