简体   繁体   English

将事件绑定到dataGrid MVVM

[英]Binding Events to dataGrid MVVM

I can't figure this thing out. 我不知道这件事。 I have been looking at it for a couple of days now and I must be missing some steps. 我已经看了几天,所以我必须错过一些步骤。 But this is my objective. 但这是我的目标。 I want to double click on a Row of a dataGrid. 我想双击dataGrid的行。
I want to take data from that data grid and use it to load a second dataGrid. 我想从该数据网格中获取数据,并使用它来加载第二个dataGrid。

I have a view model that contains two ObservableCollections 我有一个包含两个ObservableCollections的视图模型

One is going to load the other. 一个将加载另一个。 When a user double clicks one, the other should load. 当用户双击其中一个时,另一个应加载。

I can figure out how to do that in MVC, but I can't wrap my head around how to accomplish this in MVVM. 我可以弄清楚如何在MVC中执行此操作,但是我无法确定如何在MVVM中完成此操作。

IE, not using the View.xmal.cs code behind. IE,没有在后面使用View.xmal.cs代码。 I can get the event that way, but I don't want to bastardize my first MVVM project but putting stuff into the code behind. 我可以通过这种方式获得活动,但是我不想混混我的第一个MVVM项目,而是将东西放到代码中。

I am guessing I just don't understand how to do this. 我猜我只是不知道该怎么做。 Does anybody know of a good tutorial that will show how to do this? 有谁知道一个很好的教程来展示如何做到这一点? Or does anybody have an example application that will let me do this? 还是有人可以通过示例应用程序做到这一点?

An awesome explanation is posted here on how get datagridrow double click event handled. 关于如何处理datagridrow双击事件的详细说明在此处发布。 http://brentedwards.net/2012/03/11/wpf-datagridrow-double-click-with-mvvm/ http://brentedwards.net/2012/03/11/wpf-datagridrow-double-click-with-mvvm/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM