locked
Default SplashScreen showing before Extended SplashScreen

    Question

  • Im trying to add a custom splashscreen on my windows 8 store app I managed to get it to work, but the default SplashScreen still appears before my Custom one.

    This is my SplashScreen XAML:

    <Page
    x:Class="CartuxaTablet.ExtendedSplash"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:CartuxaTablet"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    
    <Grid Background="#FF0000">
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="180"/>
        </Grid.RowDefinitions>
    
        <Canvas Grid.Row="0">
            <Image x:Name="extendedSplashImage" Source="ms-appx:///Assets/splash.png" Canvas.Left="158" Canvas.Top="48" />
        </Canvas>
        <StackPanel Grid.Row="1" HorizontalAlignment="Center">
            <ProgressRing IsActive="True"></ProgressRing>
        </StackPanel>
    </Grid>

    and the code behind:

    namespace CartuxaTablet
    {
        /// <summary>
        /// An empty page that can be used on its own or navigated to within a Frame.
        /// </summary>
        partial class ExtendedSplash
        {
            internal Rect splashImageRect; // Rect to store splash screen image coordinates.
            internal bool dismissed = false; // Variable to track splash screen dismissal status.
            internal Frame rootFrame;
    
            private SplashScreen splash; // Variable to hold the splash screen object.
    
            public ExtendedSplash(SplashScreen splashscreen, bool loadState)
            {
                InitializeComponent();
    
    
                // Listen for window resize events to reposition the extended splash screen image accordingly.
                // This is important to ensure that the extended splash screen is formatted properly in response to snapping, unsnapping, rotation, etc...
                Window.Current.SizeChanged += new WindowSizeChangedEventHandler(ExtendedSplash_OnResize);
    
                splash = splashscreen;
    
                if (splash != null)
                {
                    // Register an event handler to be executed when the splash screen has been dismissed.
                    splash.Dismissed += new TypedEventHandler<SplashScreen, Object>(DismissedEventHandler);
    
                    // Retrieve the window coordinates of the splash screen image.
                    splashImageRect = splash.ImageLocation;
                    PositionImage();
                }
    
                // Create a Frame to act as the navigation context
                rootFrame = new Frame();
    
                // Restore the saved session state if necessary
                RestoreStateAsync(loadState);
            }
    
            async void RestoreStateAsync(bool loadState)
            {
                if (loadState)
                    await SuspensionManager.RestoreAsync();
    
                // Normally you should start the time consuming task asynchronously here and
                // dismiss the extended splash screen in the completed handler of that task
                // This sample dismisses extended splash screen  in the handler for "Learn More" button for demonstration
            }
    
            // Position the extended splash screen image in the same location as the system splash screen image.
            void PositionImage()
            {
                extendedSplashImage.SetValue(Canvas.LeftProperty, splashImageRect.X);
                extendedSplashImage.SetValue(Canvas.TopProperty, splashImageRect.Y);
                extendedSplashImage.Height = splashImageRect.Height;
                extendedSplashImage.Width = splashImageRect.Width;
            }
    
            void ExtendedSplash_OnResize(Object sender, WindowSizeChangedEventArgs e)
            {
                // Safely update the extended splash screen image coordinates. This function will be fired in response to snapping, unsnapping, rotation, etc...
                if (splash != null)
                {
                    // Update the coordinates of the splash screen image.
                    splashImageRect = splash.ImageLocation;
                    PositionImage();
                }
            }
    
    
    
            // Include code to be executed when the system has transitioned from the splash screen to the extended splash screen (application's first view).
            void DismissedEventHandler(SplashScreen sender, object e)
            {
                dismissed = true;
    
                // Navigate away from the app's extended splash screen after completing setup operations here...
                // This sample navigates away from the extended splash screen when the "Learn More" button is clicked.
            }
        }
    }

    and on my App.Xaml.cs i added this:

    if (e.PreviousExecutionState != ApplicationExecutionState.Running)
                {
                    bool loadState = (e.PreviousExecutionState == ApplicationExecutionState.Terminated);
                    ExtendedSplash extendedSplash = new ExtendedSplash(e.SplashScreen, loadState);
                    Window.Current.Content = extendedSplash;
                }
    
                Window.Current.Activate();

    Do i need to do something extra to disable the default Splash Screen? Or do i have to use both of them ?

    • Edited by Thought2 Wednesday, February 19, 2014 10:51 AM
    Wednesday, February 19, 2014 10:49 AM

Answers

  • no you cant remove the default splashscreen. the idea of the extended is to show it as soon as possible but till that the default one will be shown

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Wednesday, February 19, 2014 12:17 PM
  • Like Dave says, you cannot remove the default splash screen. It runs while the Windows is setting up the process before any of your app's code runs. The extended splash is part of the app logic and runs while the app is doing its own initialization.

    --Rob

    Wednesday, February 19, 2014 3:46 PM
    Owner

All replies

  • no you cant remove the default splashscreen. the idea of the extended is to show it as soon as possible but till that the default one will be shown

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Wednesday, February 19, 2014 12:17 PM
  • So i need to make them identical so that the transition from one to another ins't noticed?
    Wednesday, February 19, 2014 12:32 PM
  • yes or start an animation that fades there to another

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Wednesday, February 19, 2014 1:09 PM
  • Like Dave says, you cannot remove the default splash screen. It runs while the Windows is setting up the process before any of your app's code runs. The extended splash is part of the app logic and runs while the app is doing its own initialization.

    --Rob

    Wednesday, February 19, 2014 3:46 PM
    Owner