WPF MVVM: Binding a different ViewModel to each TabItem?

前端 未结 5 1150
庸人自扰
庸人自扰 2020-12-28 17:22

I have a main window with a tab control containing 2 tabItems:

\"Main

I currently

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-28 17:32

    I use a framework such as Prism, that allows you to define regions and use the RegionManager. You can then define a ContentControl as the 'ui' for the TabItem

    Then you can use the RegionManager.RequestNavigate to populate a named region with a particular view (and our views import a viewmodel and set their datacontext).

提交回复
热议问题