{结合},{结合Data.XXX},{绑定路径= XXX}等人在WPF [英] {Binding}, {Binding Data.XXX}, {Binding Path=XXX} and others in WPF

查看:171
本文介绍了{结合},{结合Data.XXX},{绑定路径= XXX}等人在WPF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也跟着不同的教程和例子,他们给我看了这些不同类型的约束力,但我不明白何时使用1,何时使用另一种。

I followed different tutorials and example and they showed me those different type of binding but I can't understand when to use one and when use another.

例如有时我看干脆:

Binding="{Binding}"

有时(这我知道如何使用它)设置后,的DataContext

Binding="{Binding Propriety1}"

在DevEx preSS GridControl我看到:

In DevExpress GridControl i see:

Binding="{Binding Data.ProprietyName}"

和其他人。结果
可以简要解释疏通为何如此不同的情况?我在网上搜索,但教程只说是什么绑定是(我知道是什么)和一个简单的例子,像我写的三分之一。

And others.
Can one explain shortly and clear why so different cases? I searched online but the tutorials say only what binding is (and I know what is) and a simple example like the third I wrote.

感谢您提前。

推荐答案

K这里是你要的简单的解释:

K here's the simple explanation you asked for:

Binding="{Binding}"

这是当你绑定的DataContext 对象本身。所以,无论是的DataContext 在当前范围内,其中的结合是被绑定。这也可以写成绑定={结合}

that is when you're binding the DataContext object itself. So whatever is the DataContext in the current scope where the binding is what is being bound. that can also be written as Binding="{Binding .}"

下一页:

Binding="{Binding Propriety1}"

在这里,我们结合 Propriety1 中的电流的DataContext 。这一次是一样的 {结合DataContext.Propriety1,的RelativeSource = {自我的RelativeSource}}/>

Here you're binding Propriety1 within the current DataContext. This one is the same as {Binding DataContext.Propriety1, RelativeSource={RelativeSource Self}}" />

最后:

Binding="{Binding Data.ProprietyName}"

在这里,我们结合 ProprietyName 属于数据这是在当前<$ C声明的属性$ C>的DataContext

所有这些都显示在该例如:下载链接

All these are shown in this example: Download Link

<StackPanel x:Name="LayoutRoot">
  <TextBlock DataContext="{Binding TestStringOne}"
              Text="{Binding}" />
  <TextBlock DataContext="{Binding TestStringOne}"
              Text="{Binding .}" />
  <TextBlock Text="{Binding TestStringTwo}" />
  <TextBlock Text="{Binding Data.TestStringThree}" />
</StackPanel>

属性和数据对象的类可以在 MainViewModel.cs 这些发现

The properties and Data object's class you can find in MainViewModel.cs for these

这篇关于{结合},{结合Data.XXX},{绑定路径= XXX}等人在WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆