我知道这听起来可能有点疯狂,但我理解的目的,你会如何解释,在这种错误设置Window.DataContext
到MainWindow
结果:主窗口的DataContext StackOverflowException
"Exception of type 'System.StackOverflowException' was thrown."
<Window>
<Window.DataContext>
<local:MainWindow />
</Window.DataContext>
</Window>
令人难以置信的智能!事实上,我试图理解为什么在后台代码中的绑定不像在ViewModel中那样工作,所以我来到这个实验中。您的自绑定是实现该目的的方法。 – usefulBee