【发布时间】:2016-12-08 14:45:08
【问题描述】:
我有一个 WPF 应用程序,它使用 MVVM 设计模式和实体框架。在这个应用程序中,我有一个 Datagrid,它具有行验证,并且工作得很好。单元格有红色边框,Datagrid 行标题有红色!在里面,正是我想要的。
然后我希望能够双击行标题来执行一些操作,所以我有以下将事件绑定到我的 ViewModel
<DataGrid.RowHeaderTemplate>
<DataTemplate>
<ContentControl >
<Label Content=" ">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<cmd:EventToCommand
Command="{Binding Main.SomeCommand, Source={StaticResource Locator}}"
CommandParameter="{Binding Path=SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Label>
</ContentControl>
</DataTemplate>
</DataGrid.RowHeaderTemplate>
现在添加它会删除红色!在行标题上指示该行中的错误。
我现在无法弄清楚如何在行验证中显示错误以及让我的项目添加交互触发器以绑定命令。
无论我以自定义样式触发器或自定义 DataGrid RowValidationErrorTemplates 的方式添加什么,它都会被我的 RowHeaderTemplate 覆盖,我无法弄清楚如何将两者结合起来。
如何在 Datagrid 行标题上同时显示错误指示和交互触发器?
【问题讨论】: