我有一个DataGrid样式模板,我希望添加双击行为.绑定应该是正确的,但我似乎无法得到xaml编译/工作.
All objects added to an IDictionary must have a Key attribute
or some other type of key associated with them.
下面的代码有什么问题?
<Style TargetType="{x:Type DataGridRow}">
<EventSetter Event="MouseDoubleClick" Handler="{Binding Connect}"/>
更新每个Viktor的评论(给出完全相同的错误):
<Style x:Key="dataGridRowStyle" TargetType="{x:Type DataGridRow}">
<EventSetter Event="PreviewMouseDoubleClick" Handler="{Binding Connect}"/>
解决方法:
可以使用DataGrid InputBindings来实现目标:
<DataGrid.InputBindings>
<MouseBinding MouseAction="LeftDoubleClick" Command="{Binding SomeCommand}" />
</DataGrid.InputBindings>