How to delete a row from a datagrid based upon a value from another in WPF
-
I am new to WPF, but I would like to know if someone can show me how to delete a row in one datagrid based upon a selection from another. The application uses C# and MVVM design pattern. Can anyone help? Thanks
-
I am new to WPF, but I would like to know if someone can show me how to delete a row in one datagrid based upon a selection from another. The application uses C# and MVVM design pattern. Can anyone help? Thanks
If your DataGrid utilizes the
SelectedItem
property as follows, you can get the selected row. Based on the columns in it, you can pick up the id and delete from the other grid.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
-
I am new to WPF, but I would like to know if someone can show me how to delete a row in one datagrid based upon a selection from another. The application uses C# and MVVM design pattern. Can anyone help? Thanks
I would use linq to identify the record to be deleted and then remove it from the list
classname Instance = Listname.Where(x=>x.Field = Criteria).FirstOrDefault();
if(Instance !=Null)
{ListName.Remove(Instance);}Never underestimate the power of human stupidity RAH
-
If your DataGrid utilizes the
SelectedItem
property as follows, you can get the selected row. Based on the columns in it, you can pick up the id and delete from the other grid.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
How would this work in MVVM? As the application has been built using this design pattern.
-
I would use linq to identify the record to be deleted and then remove it from the list
classname Instance = Listname.Where(x=>x.Field = Criteria).FirstOrDefault();
if(Instance !=Null)
{ListName.Remove(Instance);}Never underestimate the power of human stupidity RAH
How would this work in MVVM? As the application has been built using this design pattern.
-
How would this work in MVVM? As the application has been built using this design pattern.
Member 2972992 wrote:
As the application has been built using this design pattern
This indicates it was not built by you and it seem you have limited exposure to MVVM or Silverlight. It is going to be a little difficult to explain in a forum post, you have a learning curve in front of you that is going to include at least 1 book!
Never underestimate the power of human stupidity RAH
-
How would this work in MVVM? As the application has been built using this design pattern.