What is the best way to share data between a WPF window and its User Controls?

前端 未结 3 626
死守一世寂寞
死守一世寂寞 2021-01-05 09:46

WPF can be infuriating sometimes.

I have a fairly simple application that consists of a single main window that contains a tab control and several tabs. I did not l

3条回答
  •  难免孤独
    2021-01-05 10:39

    In the declaration of your user control you could just set the data context to the instance of the object that contains all the things you need to bind to!

    Then you can access the properties of that objects' instance within the user control as you normally would.

提交回复
热议问题