locked
Help With Extended Splash Screen in GridView App RRS feed

  • Question

  • I have a page called ExtendedSplash.xaml which looks like the following:

    <Grid>
       
    <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
               
    <Image x:Name="extendedSplashImage" Source="images/splash.png" Stretch="None" />
               
    <ProgressRing x:Name="ProgressRing" Foreground="White" IsActive="True" Height="30" Width="30" Margin="20" />
       
    </StackPanel>
    </Grid>

    The code behind ExtendedSplash.xaml.cs looks like the following:

    public MainPage(SplashScreen splash)
    {  
       
    InitializeComponent();
    }

           
    internal void onSplashScreenDismissed(Windows.ApplicationModel.Activation.SplashScreen sender, object e)
    {
    }

    At the moment I fetch data from a RSS feed and bind to the GridView in the page GroupedItemsPage.xaml and he code behind is as follows:

    private async void GetFeed()
    {
      progressRing.IsActive = true;
      CoreDispatcher dispatcher = Window.Current.Dispatcher;
      await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
      {
        var sampleDataGroups = SampleDataSource.GetGroups("AllGroups");
        this.DefaultViewModel["Groups"] = sampleDataGroups;
        progressRing.IsActive = false;
      });
    }

     Where I am stuff is the App.xaml page as I don't know where to put things.  The code behind looks like the following at the moment:

    protected override async void OnLaunched(LaunchActivatedEventArgs args)
            {
                Frame rootFrame = Window.Current.Content as Frame;

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
               
                if (rootFrame == null)
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    rootFrame = new Frame();
                    //Associate the frame with a SuspensionManager key                               
                    SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

                    if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                    {
                        // Restore the saved session state only when appropriate
                        try
                        {
                            await SuspensionManager.RestoreAsync();
                        }
                        catch (SuspensionManagerException)
                        {
                            //Something went wrong restoring state.
                            //Assume there is no state and continue
                        }
                    }

                    // Place the frame in the current Window
                    Window.Current.Content = rootFrame;
                }
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    if (!rootFrame.Navigate(typeof(GroupedItemsPage), "AllGroups"))
                    {
                        throw new Exception("Failed to create initial page");
                    }
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }

     Any help on how to launch the splash screen, get RSS data and hide the splash screen to navigate to the app witll be great thanks.
    Tuesday, April 23, 2013 11:22 AM

Answers

  • All You Have To Do Is Extend the Splash Screen. The Splash Screen Will Navigate Away Once The RSS Feed Has Been Get And Loaded :).

    I Answered A Similar Question On How To Extend A Splash Screen Here

    If This Helps You Please Mark This Answer As To Help Other Developers Who Will Have The Same Problem In The Near Future.

    :)


    • Marked as answer by Aaron Xue Wednesday, May 8, 2013 10:02 AM
    Tuesday, April 23, 2013 7:49 PM
  • I suggest initiating the load in app not mainpage, perhaps something like this (I removed the suspend/restore stuff to keep it simple):

      protected async override void OnLaunched(LaunchActivatedEventArgs args)
      {
        Window.Current.Content = new MyExtendedSplash(args.SplashScreen);
        Window.Current.Activate();
    
        await MyDataModel.LoadFeedAsync();
    
        Frame rootFrame = new Frame();
        Window.Current.Content = rootFrame;
        rootFrame.Navigate(typeof(MainPage)); // show after data is loaded
      }

    • Marked as answer by Aaron Xue Wednesday, May 8, 2013 10:02 AM
    Wednesday, April 24, 2013 2:02 AM

All replies

  • All You Have To Do Is Extend the Splash Screen. The Splash Screen Will Navigate Away Once The RSS Feed Has Been Get And Loaded :).

    I Answered A Similar Question On How To Extend A Splash Screen Here

    If This Helps You Please Mark This Answer As To Help Other Developers Who Will Have The Same Problem In The Near Future.

    :)


    • Marked as answer by Aaron Xue Wednesday, May 8, 2013 10:02 AM
    Tuesday, April 23, 2013 7:49 PM
  • In the link you provided it shows a button to click to navigate away.  Do you have some code that can show in C# how the extended splash is dismissed once all the RSS data is loaded?
    Tuesday, April 23, 2013 11:05 PM
  • I suggest initiating the load in app not mainpage, perhaps something like this (I removed the suspend/restore stuff to keep it simple):

      protected async override void OnLaunched(LaunchActivatedEventArgs args)
      {
        Window.Current.Content = new MyExtendedSplash(args.SplashScreen);
        Window.Current.Activate();
    
        await MyDataModel.LoadFeedAsync();
    
        Frame rootFrame = new Frame();
        Window.Current.Content = rootFrame;
        rootFrame.Navigate(typeof(MainPage)); // show after data is loaded
      }

    • Marked as answer by Aaron Xue Wednesday, May 8, 2013 10:02 AM
    Wednesday, April 24, 2013 2:02 AM