我使用FindAncestor和AncestorLevel=3到达顶层标记,该标记应该有viewModel中继命令,但它不起作用。如果我做错了,有什么建议或调试这个场景的方法吗?
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding name}" Cursor="Hand"
Foreground="Blue" TextDecorations="Underline">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDown">
<cmd:EventToCommand Command="{Binding NameClickCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=Grid, AncestorLevel=3}}"
MustToggleIsEnabled="True" PassEventArgsToCommand="True"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>发布于 2011-01-27 01:21:46
它看起来像是将命令绑定到网格上一个名为NameClickCommand的属性。Grid没有此属性,因此请尝试将其更改为
Command="{Binding Path=DataContext.NameClickCommand...如果NameClickCommand在网格的DataContext中
发布于 2011-01-27 00:25:50
您正在寻找层次结构中的第三个Grid --这是您想要的吗?
请注意,Grid不包括DataGrid。
https://stackoverflow.com/questions/4806895
复制相似问题