I have a parent window which has a ListView that is bound to an ObservableCollection that gets it's data from an XML file. On the parent window, I have an add button that opens a opens a Modal Window (form2.ShowDialog(), I think this is a Modal window).
In the child window I have a few text fields and an add button, the user enters data for a new record and clicks the Add button and the XML file is updated with the new record.
What I am seeking to do is when the child window is closed that the ListView in the parent window is refreshed to show the new record.
When I am updating the XML file from the child window, I am doing this directly to the XML file, should I be adding the data to the file in some other manner which would raise an event on the ObservableCollection?
I was heading down the path of adding an event handler to the add button on the parent window and attempt to force a re-read of the XML file, but I cannot figure out how to achieve this, below is what I have done so far.
form1.xaml.vb:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
Dim frm As New newEmergencyContact
AddHandler frm.Closed, AddressOf refresh_EmContacts
frm.ShowDialog()
End Sub
Private Sub refresh_EmContacts()
End Sub
I cannot workout what should go into the refresh_EmContacts sub, do I need to call some kind of ObservableCollection event handler to notify it that it has been updated and to do the re-read?
Any assistance would be greatly appreciated.
Matt