在这里,我混淆了{ binding }和{binding Account}绑定,只使用简单的{ binding },并且在下面的代码绑定中使用正确名称的绑定发生为:Content="{Binding}“
<Border Grid.Row="1" Grid.Column="0"
Style="{StaticResource MainBorderStyle}"
Background="{StaticResource ResourceListGradientBrush}"
BorderThickness="0,0,1,1"
Padding="0">
<StackPanel>
<HeaderedContentControl
Content="{Binding}"
ContentTemplate="{StaticResource CommandsTemplate}"/>
</StackPanel>
</Border>以下是代码绑定发生的方式
Text="{Binding Path=Name, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}"/>所以我想提前了解它们的用法和them.thank的区别。
发布于 2012-04-26 08:54:03
{Binding}将简单地绑定到DataContext中的实际对象集。{Binding Account}将绑定到该对象上的属性Account。
在您的示例中,如果针对根级别DataContext设置了ViewModel,则Account将是ViewModel上名为Account的属性
你有的地方
<HeaderedContentControl
Content="{Binding}"
ContentTemplate="{StaticResource CommandsTemplate}"/>所要做的就是将HeaderedContentControl的Content设置为ViewModel,前提是在Window或UserControl后面的代码中有类似这样的内容
DataContext = yourViewModel;发布于 2012-04-26 08:54:11
{Binding}将绑定到当前的DataContext
{Binding Account}将绑定到当前DataContext上的Account属性
https://stackoverflow.com/questions/10325794
复制相似问题