Binding ViewModel to multiple windows

后端 未结 4 812
醉话见心
醉话见心 2021-02-14 21:37

I\'m re-writing my windows forms project that does scoring for sheep shearing events (don\'t ask, its a huge sport in New Zealand) from vbnet to wpf c# and have struck a problem

4条回答
  •  遇见更好的自我
    2021-02-14 22:08

    I would make the ViewModel as an application resource

    
        
        ....
    
    

    then in the each window you call it like this

    DataContext="{StaticResource MainViewModel}"
    

    I'm still new to this concept, and I'm not sure if this is optimal. It works though!

提交回复
热议问题