Click here to Skip to main content
15,920,633 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all


I have a child window having a save button.On click of save I have to submit the data and close the window.i have created a class called commonentities.cs in silverlight and is having a save method.(I have created a seperate method to save because that method is calling from another page also.).Now,the function from commonentities.cs is called on save click of child window.How do I close the window from the commonEntities.cs class.

EG:
<pre>public class CommonEntities
{
public void save()
{
--------- save functionality---------
service.Savecompleted()+=>(se,ev)
{
--- Close the child window here,from which this class is called?????????????
};
service.SaveAsync()
}
}</pre>

The above method is called from ChildWindow.

Thanks
Piyush
Posted
Updated 26-Jul-11 1:50am
v2

You don't close it from the external class. Create a custom event in the external class that reflects the service's SaveAsync_Complete event (assuming the service reference isn't public (and it shouldn't be), and hook that event from the child window. When the window gets the event, it can close itself.
 
Share this answer
 
Comments
Piyush Nandanwar 26-Jul-11 7:59am    
Hi John, can u elaborate ur answer?? means can u plz provide me a code??
Hi,

I got the solution and it works like a charm.

When you create a class object from child window,pass "this" object(it represents the child window object) to constructor of class,assign "this" object of child window to the global object of type of child window.

Now,in class, call the DialogResult property of global object of child window,whenever u want to close the window.

In above example class is <b>CommonEntities</b>

Thanks and Cheers !!!
Piyush
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900