Skip to content

Using TabControl to display tabbed panels with varying content #17537

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

You must be logged in to vote

Making Tabs a collection of TabItem means the contained ViewModels would have to derive from TabItem?

Nope. In fact, doing that would be a major MVVM violation. When binding to an items control from a view model, you generally don't have to worry about the container control. The control will set it up for you.

I think the missing link is to provide the ItemsSource with the Views associated with the ViewModels (the models are contained in the TabControl). But I do not know how to do that...

You can either use a ViewLocator, or you need to specify a DataTemplate.

https://docs.avaloniaui.net/docs/concepts/view-locator
https://docs.avaloniaui.net/docs/basics/data/data-templates

I would su…

Replies: 3 comments 8 replies

Comment options

You must be logged in to vote
3 replies
@thevortexcloud
Comment options

@ortwinrose
Comment options

@thevortexcloud
Comment options

Answer selected by ortwinrose
Comment options

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

@thevortexcloud
Comment options

@ortwinrose
Comment options

@thevortexcloud
Comment options

Comment options

You must be logged in to vote
1 reply
@thevortexcloud
Comment options

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