Erika
Erika

Reputation: 289

How to show Master Detail information in a new dialog box c# wpf

I have a datagrid with a list of "JobItem" objects, and when I select an item from this list, I want to be able to open it up in a new window and be able to edit its properties and save it. I have the databinding part of it, I just don't understand how I can pass the object instance that I selected from datagrid, and have its information populated in the new window. I found the exact project in codeproject that did what I wanted to do and looked at the code but I still could not figure out who this object instance was passed. The article is:

http://www.codeproject.com/Articles/332615/WPF-Master-Details-MVVM-Application

Upvotes: 1

Views: 607

Answers (1)

Yatrix
Yatrix

Reputation: 13775

Cast the ListViewItem to the object.

`(ObjectType)YourListView.SelectedItem` 

will give you an instance of the class, if that's what you're asking.

You can then pass it to the edit form through it's constructor. If you pass it by value, you'll have to write some update code in the original form to "merge" the changes.

I think if you pass it by reference, it'll update the listview on it's on if you have it set up correctly with INotifyPropertyChanged. You may want to test that to make sure, though. I'm not 100% on that.

Upvotes: 2

Related Questions