更新时间:2021-10-10 03:04:19
在此处有一条评论,说:
只是要在此处说明如果要绑定到那么您必须明确指定RelativeSource的DataContext :{Binding Path = DataContext.SomeProperty,RelativeSource =....这是当我尝试绑定到一个新手时,对我来说有些意外父对象在DataTemplate中的DataContext.
Just wanted to note here that if you want to bind to a property in the DataContext of the RelativeSource then you must explicitly specify it: {Binding Path=DataContext.SomeProperty, RelativeSource=.... This was somewhat unexpected for me as a newbie when I was trying to bind to a parent's DataContext within a DataTemplate.
此评论值得更多关注,因此我将其用作正确答案.
This comment deserves more attention, so I'll use it as the correct answer.