在WPF绑定中,空{绑定}做什么[重复]

时间:2022-08-27 00:06:07

This question already has an answer here:

这个问题在这里已有答案:

In WPF binding what does an empty {Binding} do?
for example:

在WPF绑定中,空{绑定}做什么?例如:

<TextBlock  Text='{Binding}' /> 

Is there an example where it is useful.

是否有一个有用的例子。

1 个解决方案

#1


1  

It binds directly to the object in the current DataContext and is equivalent to

它直接绑定到当前DataContext中的对象,相当于

Text="{Binding Path=.}"

When the target property of the Binding is of type string (as e.g. the Text property of a TextBlock), built-in type conversion calls the object's ToString method (if it is not already a string).

当Binding的target属性是string类型(例如TextBlock的Text属性)时,内置类型转换调用对象的ToString方法(如果它不是字符串)。

#1


1  

It binds directly to the object in the current DataContext and is equivalent to

它直接绑定到当前DataContext中的对象,相当于

Text="{Binding Path=.}"

When the target property of the Binding is of type string (as e.g. the Text property of a TextBlock), built-in type conversion calls the object's ToString method (if it is not already a string).

当Binding的target属性是string类型(例如TextBlock的Text属性)时,内置类型转换调用对象的ToString方法(如果它不是字符串)。