问题描述
我已经看到这种语法出现,并试图用谷歌搜索它的定义,但无济于事;以这种方式绑定 dp 是什么意思?
I've seen this syntax show up, and have tried to google for it's definition to no avail; what does it mean when a dp is bound this way?
<Grid>
<ContentControl Content="{Binding}"/>
</Grid>
我假设您必须绑定到 DataContext 上的某些属性或其他元素,但这似乎没有绑定.
I was under the assumption that you have to bind to some property on the DataContext, or another element, but this appears to bind to nothing.
推荐答案
我相信这意味着您正在绑定到任何绑定上下文的根.因此,如果您在属于某种列表控件的数据模板中使用此语法,您将绑定到父控件(列表控件)绑定到的任何根级别.
I believe it means you are binding to the root of whatever the binding context is. So if you use this syntax in a datatemplate that is part of some sort of list control, you would be binding to the root level of whatever the parent control (the list control) was binding to.
这篇关于WPF 绑定语法问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!