In WPF, we have a Page class that allows us to use a multi-page interface in a single window. How to do it in Avalonia?
In WPF, we have a Page class that allows us to use a multi-page interface in a single window. How to do it in Avalonia?
What you're describing is often solved with a TabControl.
Each tab can have a TabViewModel derived class instance to bind to as its data context.
TabAViewModel : TabViewModel
{
}
TabBViewModel : TabViewModel
{
}
These can then have their own views *.axaml files ... so TabAView.axaml & TabBView.axaml in this instance. They can contain any arbitrary UI. Full screens of stuff or as little as a Path.
<UserControl>
...
</UserControl>
You can then have a collection of those that the TabControl binds too, so on something akin to a MainViewModel.cs ...
MainViewModel : MyBaseViewModel
{
public ObservableCollection<TabViewModel> MyTabs { get; ... }
}
MainView.axal would then look like this.
<Window>
<TabControl Items={Binding MyTabs}>
<TabControl.DataTemplates>
<TabAView />
</TabControl.DataTemplates>
</TabControl>
</Window>
Now be warned. This is pseudocode, but it explains the concepts and how things can hang together. I've done this in WPF and Avalonia.
Why Pseudocode?
Depending on what frameworks you are using they would drastically change the implementation details on how to do this.
In Prism you would need to implement a RegionAdaptor, in Avalonia you'd possibly need a DataTemplateSelector to wire up Views to ViewModels, in WPF this just more or less works out the box.
Either way, the concept is valid in each.