Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想要一个可以从多个视图中看到的对象。每个视图都有一个 Viewmodel。
是否有可能拥有一个“全局”视图模型以及我可以从应用程序的所有视图绑定的对象?
是的当然。这通常在“ViewModelLocator”模式中完成 - 谷歌会为您指出大量示例,但这是一个很好的开始:
https://web.archive.org/web/20170222162805/http://www.terrymarshall.com.au/Blog/tabid/162/EntryId/117/Windows-8-and-MVVM-Part-3-ViewModelLocator。 aspx