在WPF中应用ViewModelLocator
<Window x:Class="Demo.Views.MainWindow"
    ...
    xmlns:prism="http://prismlibrary.com/"
    prism:ViewModelLocator.AutoWireViewModel="True">

约束:

  • ViewModel与视图类型位于同一个程序集中
  • ViewModel位于.ViewModels子命名空间中
  • 视图位于.Views子命名空间中
  • ViewModel名称与视图名称对应,以“ViewModel”结尾。

 不然无法解析

相关文章:

  • 2022-02-09
  • 2021-09-13
  • 2021-05-20
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2021-09-05
  • 2022-12-23
猜你喜欢
  • 2022-03-02
  • 2022-01-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-22
相关资源
相似解决方案