是否有可能获得Silverlight的第一个加载事件(ie.check条件取决于第一个加载事件) [英] Is it possible to get Silverlight's first load event (ie.check condition depends on first load event)

查看:52
本文介绍了是否有可能获得Silverlight的第一个加载事件(ie.check条件取决于第一个加载事件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设,

我在项目中有三个页面。(主页,登录,第三个)

当我启动项目时,主页打开(mainpage.xmal)



i想要两个页面开始(主页,登录)

所以我这样做,

  void  MainPage_Loaded( object  sender,RoutedEventArgs e)
{
App app =(App)Application.Current;
App.Navigate( new Login());
}



启动主页面和登录页面都可以。



但是,在第三页(xxxxxx.xmal)

我必须调用主页面和NextPage

  public   void  Link_Click( object  sender,RoutedEventArgs e)
{
App.Navigate( new MainPage());
App.Navigate( new NextPage());
}





现在,这是MainPage调用登录页面的问题。那时候调用登录页面是不行的。

描述在我的问题中,



是否有可能使检查条件取决于首次加载事件?

例如

if(silverlight项目第一次加载)

{

// OK

}





如何在初始时显示两页而不是再次打电话给主页

感谢您的任何建议或如果它是一个登录页面,那么你应该保持登录状态(可能在静态类中),然后在页面加载的事件中测试它。如果它是一个登录页面,那么你应该保持登录状态(.class class =因此,第一次加载主页时,检查有效登录名将为false,您将重定向到登录页面。后续调用将测试并看到登录已成功完成,并跳过跳转到登录页面。


您可以创建MainPage的参数化构造函数,如



公共主页(bool isLogedIn)

{

if(isLogedIn)

{



}

其他

{



}



}



然后拨打您的MainPage;


Suppose,
I have three pages in project.(mainpage,loginin,third)
when i start the project, mainpage opens(mainpage.xmal)

i want to make both two pages starts(mainpage,login)
so i make like this,

void MainPage_Loaded(object sender, RoutedEventArgs e)
       {
           App app = (App)Application.Current;
           App.Navigate(new Login());
        }


It is Ok to start both main page and login page.

But,in third page(xxxxxx.xmal)
I have to call main page and NextPage

public void Link_Click(object sender, RoutedEventArgs e)
        { 
                    App.Navigate(new MainPage());
                    App.Navigate(new NextPage());
           }



Now, that is the problem that MainPage call Login Page .That time is not OK to call Login Page.
Described In my question,

is it possible to make check condition depends on first load event?
eg
if (silverlight project first time load)
{
//OK
}

Or
How can i make show two pages at initial and than call main page only again
Thanks for any suggestions or advice.

解决方案

If it is a login page then you should persist the login status (probably in a static class) and then test for it in the page loaded events. So the first time the mainpage is loaded, the check for a valid login would be false and you would redirect to the login page. Subsequent calls would test and see that login has been completed successfully and would skip the jump to the login page.


you can create a parameterized Constructor of your MainPage like

public MainPage(bool isLogedIn)
{
if(isLogedIn)
{

}
else
{

}

}

and then call your MainPage;


这篇关于是否有可能获得Silverlight的第一个加载事件(ie.check条件取决于第一个加载事件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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