In this short post I will show you how you can use the child window control of silver light 3 and get the values from the child window control. Let us start with our code, when you add new item from the add new item option you can see the Silverlight Child window template when you click on the Silverlight category. When you add it it will generate two buttons and there click event handler and code in there click event handler, the Dialog-return true for OK and false for cancel button. Below is the main screen of the child window here you can see the I have create the First Name , Last Name , Email address and the contact Number.
Here is my code to open the child window control from the code. Here you can see that I have created the childWindow object and then registered the closed event handler for the object. The reason for registering the closed event handler is that Show() is an asynchronous call. That is, it doesn't wait for the dialog to be dismissed; it returns immediately. That's why Show() returns void rather than a DialogResult. If you want to know how the dialog was dismissed (that is, what the DialogResult value is once the dialog is closed), you handle the dialog's Closed event and check DialogResult there.
And in the closed event handler I have check for the DialogResult for the HasValue and check for the value. The HasValue indicate whether the current dialogResult has value or not and the value property of the dialogResult which is nullable.
The I have used the properties of the child window control to get the values for the First Name, Last Name, Email address and contact Number. The value to these properties are assigned on the click event handler of the OK button and in that click event handler DialogResult is assign value true and in the cancel click event handler the value is assigned to false., these value are assigned when you add new item of child window control.Hope you get some understanding of the child window control and how to return values from the child window control. You can download the source code from here
All and any comments / bugs / suggestions are welcomed!