901225-关闭页面进行最终工作时应处理什么事件? [英] 901225 - what event to handle when a page is closed to do final works?

查看:72
本文介绍了901225-关闭页面进行最终工作时应处理什么事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我尝试处理主页(用户控件)和其中的图像控件的Unloaded事件.我关闭页面时都不会调用.所以我不知道活动什么时候开始.
在页面关闭之前,我需要做一些事情.这将关闭页面加载时打开的会话.
然后,另一个问题是,如果用户按下F5并刷新页面,是否再次调用Loaded事件并打开一个新会话而没有关闭前一个会话?
听起来我是Silverlight的新手.的确是这样:)
感谢您的答复

解决方案

公共MainPage()
{
InitializeComponent();
App.Current.MainWindow.Closing + =新的EventHandler< System.ComponentModel.ClosingEventArgs>(MainWindow_Closing);
}

void MainWindow_Closing(对象发送者,System.ComponentModel.ClosingEventArgs e)
{

//在这里做所有的事情....

}

Thankz ....:)


是加载的事件(只是再次调用了xaml文件的构造函数)

并且触发了aspx页面加载事件.在Silverlight中产生的会话已清除..


hi i tried handling Unloaded event for the main page (user control) and the image control inside it. neither is called when i close the page. so i don''t know when the event is raised.
i need to do something before the page is closed. that''s closing the session i''ve opened when the page is loaded.
then, another question, if the user hit F5 and refresh the page, does Loaded event get called again and a new session is opened without the previous one is closed?
it sounds i''m a newbie in Silverlight. indeed, it''s the case :)
appreciating ur replies

解决方案

public MainPage()
{
InitializeComponent();
App.Current.MainWindow.Closing += new EventHandler<System.ComponentModel.ClosingEventArgs>(MainWindow_Closing);
}

void MainWindow_Closing(object sender, System.ComponentModel.ClosingEventArgs e)
{

// Do all stuff here ....

}

Thankz .... :)


Ya the loaded event ( its just the constructor of the xaml file is called again )

and the aspx page load event is fired . Sessions produced in silverlight are cleared ..


这篇关于901225-关闭页面进行最终工作时应处理什么事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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