One of my favorite features of SL 4 is the childwindow. You can add a window to your project just like in WPF and then add all the xaml to it. Then define it in your code. For instance, the following code references a childwindow called ItemMaintenance. Its creates a new instance of it, then wires up a closed event, then shows the window.

ItemMaintenance = new ContactsMaintenanceChildWindow(SelectedContact, _Contacts);
ItemMaintenance.Closed += ItemMaintenance_Closed;
ItemMaintenance.Show();

The close event is shown below:

private void ItemMaintenance_Closed(object sender, EventArgs e)
 {
 if (ItemMaintenance.DialogResult == true)
 {
 RefreshCount(FeatureTypeEnum.All);
 }
 else
 {
 }
 }

You must wire up the Closed event and grab the values from the childwindow from it. You can’t just put an If block around the Show method as you could in WPF or Win Form.

Latest posts by Ken Spencer (see all)