How to switch to another page by clicking a button in Avalonia Community.Toolkit? #14634
-
Actually the whole question is in the title. here is the link to the github project if needed |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
please have a look at the data template samples here: https://github.com/AvaloniaUI/Avalonia.Samples |
Beta Was this translation helpful? Give feedback.
-
As I mentioned in the last issue you opened, it sounds like you want a router |
Beta Was this translation helpful? Give feedback.
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.