将选定的行事件连接到 mvvmlight 命令
我正在编写使用 MVVMLight 的 WPF 应用程序。我有一个 DataGrid,我想将选择行的事件连接到命令。这是最简单的部分。困难的(当然对我来说;])部分是获取与所选行连接的实体。我怎样才能做到这一点?
I'm writing WPF application, that's using MVVMLight. I have a DataGrid and I wanna connect event of selecting row to command. That's the easy part. The hard(for me of course ;]) part is to get the entity that's connected with the selected row. How can I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你有很多方法可以做到这一点。
第一个是将选定的行作为命令参数传递。您可以通过 XAML 或代码隐藏来完成此操作。
您还可以在视图模型中创建选定项属性并将其绑定到控件。
You have many ways of doing so.
The first one would be to pass the selected row as a command parameter. You can do this by XAML or code-behind.
You can also create a selected item property in your view model and bind it to your control.