简体   繁体   中英

how to disabled selection changed in the details of the dataGrid? (MVVM)

I have a dataGrid that use Tareas as items source. This object has a property ICollection as items source of the details.

Also I have a command in my view model that has the code to execute when I select a row in my main data grid. However, when I select a row in the data grid of the details I get an error because is not possible to convert TareasHistorico to Tareas. I nthe code of the method I have a cast.

I would like to know if there is a way to avoid the execution of the selection changed in the data grid of the details.

I could use an if in my view model to check if the type that I try to cast is the expected type, but I think that this is not a good way to solve the problem, because I guess that this problem is not really a problem of the view model but it is of the view.

Thanks.

You can do below whichever u are able to get

e.Cancel = true;

or

e.Handled = true;

as First line of Code in DataGrid Selection Changed event.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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