如何关闭其他班级的子窗口 [英] How to close child window from other class

查看:83
本文介绍了如何关闭其他班级的子窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好


我有一个带有保存按钮的子窗口.单击保存后,我必须提交数据并关闭窗口.我在silverlight中创建了一个名为commonentities.cs的类,并且具有save方法.(我创建了一个单独的方法之所以要保存,是因为该方法也在另一个页面上调用.)现在,在子窗口的保存单击时调用commonentities.cs中的函数.如何从commonEntities.cs类中关闭该窗口.

EG:
< pre>公共类CommonEntities
{
公共无效的save()
{
---------保存功能---------
service.Savecompleted()+ =>(se,ev)
{
---在此处关闭子窗口,从该子窗口中调用该类?????????????
};
service.SaveAsync()
}
}</pre>

上面的方法是从ChildWindow中调用的.

谢谢
Piyush

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

推荐答案

从外部类中将其关闭.在外部类中创建一个反映该服务的SaveAsync_Complete 事件的自定义事件(假设该服务引用不是公开的(并且不应公开),然后将该事件挂接到子窗口中.窗口获取事件,它可以自行关闭.
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.




我找到了解决方案,它就像一个魅力.

从子窗口创建类对象时,将"this"对象(代表子窗口对象)传递给类的构造函数,将子窗口的"this"对象分配给子窗口类型的全局对象.

现在,在类中,每当您要关闭窗口时,都调用子窗口的全局对象的DialogResult属性.

在上面的示例中,类是< b> CommonEntities</b>

谢谢,干杯!!!
Piyush
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


这篇关于如何关闭其他班级的子窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆