WPF - Should a user control have its own ViewModel?

后端 未结 5 1015
梦毁少年i
梦毁少年i 2020-11-27 14:32

I have a window made up of several user controls and was wondering whether each user control have its own ViewModel or should the window as a whole have only one ViewModel?<

5条回答
  •  天命终不由人
    2020-11-27 14:57

    This is not a yes or no question. It depends on whether having extra view models affords you better maintainability or testability. There's no point adding view models if it doesn't gain you anything. You'll need to gauge whether the overhead is worth it to your particular use case.

提交回复
热议问题