void SetAlternativeElements(VisualElementsRequestedEventArgs args)
        {
            // Prepare the images for the alternate tile options.
            Uri alternate1Square70x70Logo   = new Uri("ms-appx:///Assets/alternate1Square70x70Tile-sdk.png");
            Uri alternate1Square150x150Logo = new Uri("ms-appx:///Assets/alternate1Square150x150Tile-sdk.png");
            Uri alternate1Wide310x150Logo   = new Uri("ms-appx:///Assets/alternate1Wide310x150Tile-sdk.png");
            Uri alternate1Square310x310Logo = new Uri("ms-appx:///Assets/alternate1Square310x310Tile-sdk.png");

            Uri alternate2Square70x70Logo   = new Uri("ms-appx:///Assets/alternate2Square70x70Tile-sdk.png");
            Uri alternate2Square150x150Logo = new Uri("ms-appx:///Assets/alternate2Square150x150Tile-sdk.png");
            Uri alternate2Wide310x150Logo   = new Uri("ms-appx:///Assets/alternate2Wide310x150Tile-sdk.png");
            Uri alternate2Square310x310Logo = new Uri("ms-appx:///Assets/alternate2Square310x310Tile-sdk.png");

            Uri alternate3Square70x70Logo   = new Uri("ms-appx:///Assets/alternate3Square70x70Tile-sdk.png");
            Uri alternate3Square150x150Logo = new Uri("ms-appx:///Assets/alternate3Square150x150Tile-sdk.png");
            Uri alternate3Wide310x150Logo   = new Uri("ms-appx:///Assets/alternate3Wide310x150Tile-sdk.png");
            Uri alternate3Square310x310Logo = new Uri("ms-appx:///Assets/alternate3Square310x310Tile-sdk.png");

            // This check verifies that we are still within the deadline to complete the request.
            // Deadline is when the fly out will time out and stop showing the progress control if the deferral has not completed by then.
            if (args.Request.Deadline > DateTime.Now)
            {
                // Set the visual elements for the alternate tile options.
                args.Request.AlternateVisualElements[0].Square70x70Logo   = alternate1Square70x70Logo;
                args.Request.AlternateVisualElements[0].Square150x150Logo = alternate1Square150x150Logo;
                args.Request.AlternateVisualElements[0].Wide310x150Logo   = alternate1Wide310x150Logo;
                args.Request.AlternateVisualElements[0].Square310x310Logo = alternate1Square310x310Logo;

                args.Request.AlternateVisualElements[0].BackgroundColor             = Colors.Green;
                args.Request.AlternateVisualElements[0].ForegroundText              = ForegroundText.Dark;
                args.Request.AlternateVisualElements[0].ShowNameOnSquare310x310Logo = true;
            }

            // If there is still time left, continue assigning assets.
            if (args.Request.Deadline > DateTime.Now)
            {
                args.Request.AlternateVisualElements[1].Square70x70Logo   = alternate2Square70x70Logo;
                args.Request.AlternateVisualElements[1].Square150x150Logo = alternate2Square150x150Logo;
                args.Request.AlternateVisualElements[1].Wide310x150Logo   = alternate2Wide310x150Logo;
                args.Request.AlternateVisualElements[1].Square310x310Logo = alternate2Square310x310Logo;

                args.Request.AlternateVisualElements[1].BackgroundColor           = Color.FromArgb(0xFF, 0x51, 0x33, 0xAB);;
                args.Request.AlternateVisualElements[1].ForegroundText            = ForegroundText.Dark;
                args.Request.AlternateVisualElements[1].ShowNameOnWide310x150Logo = true;
            }

            if (args.Request.Deadline > DateTime.Now)
            {
                args.Request.AlternateVisualElements[2].Square70x70Logo   = alternate3Square70x70Logo;
                args.Request.AlternateVisualElements[2].Square150x150Logo = alternate3Square150x150Logo;
                args.Request.AlternateVisualElements[2].Wide310x150Logo   = alternate3Wide310x150Logo;
                args.Request.AlternateVisualElements[2].Square310x310Logo = alternate3Square310x310Logo;

                args.Request.AlternateVisualElements[2].BackgroundColor             = Colors.Red;
                args.Request.AlternateVisualElements[2].ForegroundText              = ForegroundText.Light;
                args.Request.AlternateVisualElements[2].ShowNameOnSquare150x150Logo = true;
            }
        }
        // Alternate tile options for the supported tile sizes are set in the handler.
        void VisualElementsRequestedHandler(object sender, VisualElementsRequestedEventArgs args)
        {
            // Prepare the images for the alternate tile options
            Uri alternate1Square70x70Logo   = new Uri("ms-appx:///Assets/alternate1Square70x70Tile-sdk.png");
            Uri alternate1Square150x150Logo = new Uri("ms-appx:///Assets/alternate1Square150x150Tile-sdk.png");
            Uri alternate1Wide310x150Logo   = new Uri("ms-appx:///Assets/alternate1Wide310x150Tile-sdk.png");
            Uri alternate1Square310x310Logo = new Uri("ms-appx:///Assets/alternate1Square310x310Tile-sdk.png");

            Uri alternate2Square70x70Logo   = new Uri("ms-appx:///Assets/alternate2Square70x70Tile-sdk.png");
            Uri alternate2Square150x150Logo = new Uri("ms-appx:///Assets/alternate2Square150x150Tile-sdk.png");
            Uri alternate2Wide310x150Logo   = new Uri("ms-appx:///Assets/alternate2Wide310x150Tile-sdk.png");
            Uri alternate2Square310x310Logo = new Uri("ms-appx:///Assets/alternate2Square310x310Tile-sdk.png");

            Uri alternate3Square70x70Logo   = new Uri("ms-appx:///Assets/alternate3Square70x70Tile-sdk.png");
            Uri alternate3Square150x150Logo = new Uri("ms-appx:///Assets/alternate3Square150x150Tile-sdk.png");
            Uri alternate3Wide310x150Logo   = new Uri("ms-appx:///Assets/alternate3Wide310x150Tile-sdk.png");
            Uri alternate3Square310x310Logo = new Uri("ms-appx:///Assets/alternate3Square310x310Tile-sdk.png");

            // Set the assets for the alternate tile options.
            // Note that up to 3 sets of alternate options can be provided.
            // Each tile size in a given set will map to each other (for example, the second alternate medium tile option will map to the second alternate wide tile option).
            // Note that if alternates are provided for the small tile size (square70x70 logo), the default option for the small tile size must be overridden as shown earlier.
            // If neither the default option nor the alternates for the small tile size are provided, then all the medium tile size options will be scaled down to their corresponding small tile size options.
            args.Request.AlternateVisualElements[0].Square70x70Logo   = alternate1Square70x70Logo;
            args.Request.AlternateVisualElements[0].Square150x150Logo = alternate1Square150x150Logo;
            args.Request.AlternateVisualElements[0].Wide310x150Logo   = alternate1Wide310x150Logo;
            args.Request.AlternateVisualElements[0].Square310x310Logo = alternate1Square310x310Logo;

            // Set the BackgoundColor, ForegroundText, and ShowName propreties for the alternate set.
            args.Request.AlternateVisualElements[0].BackgroundColor             = Colors.Green;
            args.Request.AlternateVisualElements[0].ForegroundText              = ForegroundText.Dark;
            args.Request.AlternateVisualElements[0].ShowNameOnSquare310x310Logo = true;

            args.Request.AlternateVisualElements[1].Square70x70Logo   = alternate2Square70x70Logo;
            args.Request.AlternateVisualElements[1].Square150x150Logo = alternate2Square150x150Logo;
            args.Request.AlternateVisualElements[1].Wide310x150Logo   = alternate2Wide310x150Logo;
            args.Request.AlternateVisualElements[1].Square310x310Logo = alternate2Square310x310Logo;

            args.Request.AlternateVisualElements[1].BackgroundColor           = Color.FromArgb(0xFF, 0x51, 0x33, 0xAB);;
            args.Request.AlternateVisualElements[1].ForegroundText            = ForegroundText.Dark;
            args.Request.AlternateVisualElements[1].ShowNameOnWide310x150Logo = true;

            args.Request.AlternateVisualElements[2].Square70x70Logo   = alternate3Square70x70Logo;
            args.Request.AlternateVisualElements[2].Square150x150Logo = alternate3Square150x150Logo;
            args.Request.AlternateVisualElements[2].Wide310x150Logo   = alternate3Wide310x150Logo;
            args.Request.AlternateVisualElements[2].Square310x310Logo = alternate3Square310x310Logo;

            args.Request.AlternateVisualElements[2].BackgroundColor             = Colors.Red;
            args.Request.AlternateVisualElements[2].ForegroundText              = ForegroundText.Light;
            args.Request.AlternateVisualElements[2].ShowNameOnSquare150x150Logo = true;
        }
        void VisualElementsRequestedHandler(object sender, VisualElementsRequestedEventArgs args)
        {
            // Request the deferral object if additional time is needed to acquire or process the assets.
            // The Pin to Start Flyout will display a progress control during this time.
            VisualElementsRequestDeferral deferral = args.Request.GetDeferral();

            // This delay is to simulate doing an async operation or any processing that will
            // take a noticeable amount of time to complete.
            ThreadPoolTimer.CreateTimer(
                async(timer) =>
            {
                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                                          () =>
                {
                    this.SetAlternativeElements(args);

                    // Once the assets have been assigned, this signals the Pin to Start Flyout to show the tiles.
                    // If the deferral does not complete before the fly out times out, the default assets provided
                    // at the time when the request to pin the tile was made will be used.
                    deferral.Complete();
                });
            }, TimeSpan.FromSeconds(3));
        }
        // Alternate tile options for the supported tile sizes are set in the handler.
        void VisualElementsRequestedHandler(object sender, VisualElementsRequestedEventArgs args)
        {
            // Prepare the images for the alternate tile options 
            Uri alternate1Square70x70Logo = new Uri("ms-appx:///Assets/alternate1Square70x70Tile-sdk.png");
            Uri alternate1Square150x150Logo = new Uri("ms-appx:///Assets/alternate1Square150x150Tile-sdk.png");
            Uri alternate1Wide310x150Logo = new Uri("ms-appx:///Assets/alternate1Wide310x150Tile-sdk.png");
            Uri alternate1Square310x310Logo = new Uri("ms-appx:///Assets/alternate1Square310x310Tile-sdk.png");

            Uri alternate2Square70x70Logo = new Uri("ms-appx:///Assets/alternate2Square70x70Tile-sdk.png");
            Uri alternate2Square150x150Logo = new Uri("ms-appx:///Assets/alternate2Square150x150Tile-sdk.png");
            Uri alternate2Wide310x150Logo = new Uri("ms-appx:///Assets/alternate2Wide310x150Tile-sdk.png");
            Uri alternate2Square310x310Logo = new Uri("ms-appx:///Assets/alternate2Square310x310Tile-sdk.png");

            Uri alternate3Square70x70Logo = new Uri("ms-appx:///Assets/alternate3Square70x70Tile-sdk.png");
            Uri alternate3Square150x150Logo = new Uri("ms-appx:///Assets/alternate3Square150x150Tile-sdk.png");
            Uri alternate3Wide310x150Logo = new Uri("ms-appx:///Assets/alternate3Wide310x150Tile-sdk.png");
            Uri alternate3Square310x310Logo = new Uri("ms-appx:///Assets/alternate3Square310x310Tile-sdk.png");

            // Set the assets for the alternate tile options.
            // Note that up to 3 sets of alternate options can be provided.
            // Each tile size in a given set will map to each other (for example, the second alternate medium tile option will map to the second alternate wide tile option).
            // Note that if alternates are provided for the small tile size (square70x70 logo), the default option for the small tile size must be overridden as shown earlier. 
            // If neither the default option nor the alternates for the small tile size are provided, then all the medium tile size options will be scaled down to their corresponding small tile size options. 
            args.Request.AlternateVisualElements[0].Square70x70Logo = alternate1Square70x70Logo;
            args.Request.AlternateVisualElements[0].Square150x150Logo = alternate1Square150x150Logo;
            args.Request.AlternateVisualElements[0].Wide310x150Logo = alternate1Wide310x150Logo;
            args.Request.AlternateVisualElements[0].Square310x310Logo = alternate1Square310x310Logo;

            // Set the BackgoundColor, ForegroundText, and ShowName propreties for the alternate set.
            args.Request.AlternateVisualElements[0].BackgroundColor = Colors.Green;
            args.Request.AlternateVisualElements[0].ForegroundText = ForegroundText.Dark;
            args.Request.AlternateVisualElements[0].ShowNameOnSquare310x310Logo = true;

            args.Request.AlternateVisualElements[1].Square70x70Logo = alternate2Square70x70Logo;
            args.Request.AlternateVisualElements[1].Square150x150Logo = alternate2Square150x150Logo;
            args.Request.AlternateVisualElements[1].Wide310x150Logo = alternate2Wide310x150Logo;
            args.Request.AlternateVisualElements[1].Square310x310Logo = alternate2Square310x310Logo;

            args.Request.AlternateVisualElements[1].BackgroundColor = Color.FromArgb(0xFF, 0x51, 0x33, 0xAB); ;
            args.Request.AlternateVisualElements[1].ForegroundText = ForegroundText.Dark;
            args.Request.AlternateVisualElements[1].ShowNameOnWide310x150Logo = true;

            args.Request.AlternateVisualElements[2].Square70x70Logo = alternate3Square70x70Logo;
            args.Request.AlternateVisualElements[2].Square150x150Logo = alternate3Square150x150Logo;
            args.Request.AlternateVisualElements[2].Wide310x150Logo = alternate3Wide310x150Logo;
            args.Request.AlternateVisualElements[2].Square310x310Logo = alternate3Square310x310Logo;

            args.Request.AlternateVisualElements[2].BackgroundColor = Colors.Red;
            args.Request.AlternateVisualElements[2].ForegroundText = ForegroundText.Light;
            args.Request.AlternateVisualElements[2].ShowNameOnSquare150x150Logo = true;
        }
        void SetAlternativeElements(VisualElementsRequestedEventArgs args)
        {
            // Prepare the images for the alternate tile options.
            Uri alternate1Square70x70Logo = new Uri("ms-appx:///Assets/alternate1Square70x70Tile-sdk.png");
            Uri alternate1Square150x150Logo = new Uri("ms-appx:///Assets/alternate1Square150x150Tile-sdk.png");
            Uri alternate1Wide310x150Logo = new Uri("ms-appx:///Assets/alternate1Wide310x150Tile-sdk.png");
            Uri alternate1Square310x310Logo = new Uri("ms-appx:///Assets/alternate1Square310x310Tile-sdk.png");

            Uri alternate2Square70x70Logo = new Uri("ms-appx:///Assets/alternate2Square70x70Tile-sdk.png");
            Uri alternate2Square150x150Logo = new Uri("ms-appx:///Assets/alternate2Square150x150Tile-sdk.png");
            Uri alternate2Wide310x150Logo = new Uri("ms-appx:///Assets/alternate2Wide310x150Tile-sdk.png");
            Uri alternate2Square310x310Logo = new Uri("ms-appx:///Assets/alternate2Square310x310Tile-sdk.png");

            Uri alternate3Square70x70Logo = new Uri("ms-appx:///Assets/alternate3Square70x70Tile-sdk.png");
            Uri alternate3Square150x150Logo = new Uri("ms-appx:///Assets/alternate3Square150x150Tile-sdk.png");
            Uri alternate3Wide310x150Logo = new Uri("ms-appx:///Assets/alternate3Wide310x150Tile-sdk.png");
            Uri alternate3Square310x310Logo = new Uri("ms-appx:///Assets/alternate3Square310x310Tile-sdk.png");

            // This check verifies that we are still within the deadline to complete the request.
            // Deadline is when the fly out will time out and stop showing the progress control if the deferral has not completed by then.
            if (args.Request.Deadline > DateTime.Now)
            {
                // Set the visual elements for the alternate tile options.
                args.Request.AlternateVisualElements[0].Square70x70Logo = alternate1Square70x70Logo;
                args.Request.AlternateVisualElements[0].Square150x150Logo = alternate1Square150x150Logo;
                args.Request.AlternateVisualElements[0].Wide310x150Logo = alternate1Wide310x150Logo;
                args.Request.AlternateVisualElements[0].Square310x310Logo = alternate1Square310x310Logo;

                args.Request.AlternateVisualElements[0].BackgroundColor = Colors.Green;
                args.Request.AlternateVisualElements[0].ForegroundText = ForegroundText.Dark;
                args.Request.AlternateVisualElements[0].ShowNameOnSquare310x310Logo = true;
            }

            // If there is still time left, continue assigning assets.
            if (args.Request.Deadline > DateTime.Now)
            {
                args.Request.AlternateVisualElements[1].Square70x70Logo = alternate2Square70x70Logo;
                args.Request.AlternateVisualElements[1].Square150x150Logo = alternate2Square150x150Logo;
                args.Request.AlternateVisualElements[1].Wide310x150Logo = alternate2Wide310x150Logo;
                args.Request.AlternateVisualElements[1].Square310x310Logo = alternate2Square310x310Logo;

                args.Request.AlternateVisualElements[1].BackgroundColor = Color.FromArgb(0xFF, 0x51, 0x33, 0xAB); ;
                args.Request.AlternateVisualElements[1].ForegroundText = ForegroundText.Dark;
                args.Request.AlternateVisualElements[1].ShowNameOnWide310x150Logo = true;
            }

            if (args.Request.Deadline > DateTime.Now)
            {
                args.Request.AlternateVisualElements[2].Square70x70Logo = alternate3Square70x70Logo;
                args.Request.AlternateVisualElements[2].Square150x150Logo = alternate3Square150x150Logo;
                args.Request.AlternateVisualElements[2].Wide310x150Logo = alternate3Wide310x150Logo;
                args.Request.AlternateVisualElements[2].Square310x310Logo = alternate3Square310x310Logo;

                args.Request.AlternateVisualElements[2].BackgroundColor = Colors.Red;
                args.Request.AlternateVisualElements[2].ForegroundText = ForegroundText.Light;
                args.Request.AlternateVisualElements[2].ShowNameOnSquare150x150Logo = true;
            }
        }
        void VisualElementsRequestedHandler(object sender, VisualElementsRequestedEventArgs args)
        {
            // Request the deferral object if additional time is needed to acquire or process the assets.
            // The Pin to Start Flyout will display a progress control during this time.
            VisualElementsRequestDeferral deferral = args.Request.GetDeferral();

            // This delay is to simulate doing an async operation or any processing that will 
            // take a noticeable amount of time to complete.
            ThreadPoolTimer.CreateTimer(
                async (timer) =>
                {
                    await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                        () =>
                        {
                            this.SetAlternativeElements(args);

                            // Once the assets have been assigned, this signals the Pin to Start Flyout to show the tiles.
                            // If the deferral does not complete before the fly out times out, the default assets provided 
                            // at the time when the request to pin the tile was made will be used.
                            deferral.Complete();
                        });
                }, TimeSpan.FromSeconds(3));
        }