也许这是一个愚蠢的问题,但我找不到答案:在下面的xaml中,CommandParameter绑定到什么?或者一般而言,"{Binding}"是什么意思?
<Button Command="{Binding DataContext.DeleteCommand, ElementName=List}"
CommandParameter="{Binding}"/>发布于 2011-03-21 21:30:13
{Binding ...}是一个MarkupExtension。
在通常的形式中,它采用类似{Binding Path=someProperty, ...} (或其缩写{Binding someProperty, ...})的路径。
因此,{Binding}中的路径为空,这意味着绑定到该绑定的任何源。如果您知道{Binding}实际上与{Binding DataContext,RelativeSource={RelativeSource Self}}相同,这可能会更容易理解。
因此,在本例中,CommandParameter获取按钮的当前DataContext的值。
发布于 2011-03-21 21:32:06
空的{Binding}将把控件的当前DataContext分别传递给Executed和CanExecute方法。
https://stackoverflow.com/questions/5377690
复制相似问题