wpf datagrid 输入编辑
我希望这是一个简单的问题。我在 wpf 应用程序中有一个数据网格。其中一列是复选框列。如果单元格已被选中,用户只能选中该复选框。因此,实际上要选中任何框,用户必须双击,一次选择,然后再次选中该框。我希望用户只需单击一下即可正确选中该框。我找不到任何明显的属性来实现这一点。执行此操作的最佳方法是什么?
I hope this is a simple one. I have a datagrid in a wpf application. one of the columns is a checkbox column. the user can only check the checkbox if the cell is already selected. so in effect to check any box the user has to double click, once to select, then once more to check the box. I want the user to be able to just check the box right a way with a single click. I couldn't find any obvious properties to make this happen. what's the best way to go about doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有关其他答案,请参阅这篇帖子,但是我喜欢的答案就在底部,所以我将在这里重复一些更多细节。
答案是:不要使用 DataGridCheckBoxColumn。只需将复选框放入 DataGridTemplate 列中几乎不再需要任何工作。当您执行此操作时,它会完全按照您想要的方式响应单击。在下面的示例中,IsSelected 只是我的 ViewModel 上的自定义 bool 属性,其他所有内容都是纯 xaml。
For other answers see this SO post but the answer I liked was way at the bottom so I'll repeat it here with some more detail.
That answer was: don't use a DataGridCheckBoxColumn. It's almost no more work to just put a Checkbox in a DataGridTemplate Column. When you do this it responds to a single click exactly like you want. In the example below IsSelected is just a custom bool property on my ViewModel, everything else is pure xaml.