在App.xaml.cs中的电话应用程序初始化期间检查根帧中的条件

时间:2014-12-27 23:44:43

标签: c# windows-phone-8

我试图通过从隔离存储中获取一些值,根据以前的用户选择在Rootframe初始化中包含一个条件。

我的代码:

      private void InitializePhoneApplication()
    {
        if (phoneApplicationInitialized)
            return;

        // Create the frame but don't set it as RootVisual yet; this allows the splash
        // screen to remain active until the application is ready to render.
        RootFrame = new PhoneApplicationFrame();

        //I want to check for a condition. Was style option selected by user?

        var appStorage= IsolatedStorage.GetUserStoreforApplication();
        if(appStorage.FileExists("style");
        { 
         RootFrame.Style = Resources["RootFrameStyle"] as Style;

        }
        else {}
         RootFrame.Navigated += CompleteInitializePhoneApplication;
        // Handle navigation failures
        RootFrame.NavigationFailed += RootFrame_NavigationFailed;

        // Handle reset requests for clearing the backstack
        RootFrame.Navigated += CheckForResetNavigation;

        // Ensure we don't initialize again
        phoneApplicationInitialized = true;
    }

我尝试了正常的if-else,但条件总是返回true。有没有其他方法来检查条件,然后相应地设置RootFrame?

0 个答案:

没有答案