Quantcast
Viewing all articles
Browse latest Browse all 256

WPF tabs

I am very new to WPF and have been tasked with modifying an existing app. One thing I noticed was that the main form's TabControl is bound to an Observable collection in the MainVM, which then gets populated with DetailVM's. The TabControl is confgured to automatically load a particular type of View and bind any new element in the collection to it.

But here's the thing; the MainVM doesn't really do anything with the DetailVM's except just spawn them and hold them. So it seems to me like this is kinda breaking the entire point of WPF, separating out data and ui. If we wanted the view to use mdi windows instead of tabs, or to not use tabs at all and only display the most recently requested DetailVM, the viewmodel would be entirely unable to cope, since it's pretty much written with "tab windows" in mind.

Would it be better design to have the view manage its own tabs, and when given a new DetailVM, it decides what to do with it rather than the MainVM? Which leads to the next question, how do I do that? Don't want to call methods on the wpf view backer code, right? Have a CurrentDetail property in the MainVM, and when the view detects it changing it creates a new tab and binds it to the value?

Viewing all articles
Browse latest Browse all 256

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>