/// <summary>
        /// Provide print content for scenario 5 first page
        /// </summary>
        protected override void PreparetPrintContent()
        {
            if (firstPage == null)
            {
                firstPage = new ScenarioOutput5();
                StackPanel header = (StackPanel)firstPage.FindName("header");
                header.Visibility = Windows.UI.Xaml.Visibility.Visible;
            }

            // Add the (newley created) page to the printing root which is part of the visual tree and force it to go
            // through layout so that the linked containers correctly distribute the content inside them.
            PrintingRoot.Children.Add(firstPage);
            PrintingRoot.InvalidateMeasure();
            PrintingRoot.UpdateLayout();
        }
        /// <summary>
        /// Option change event handler
        /// </summary>
        /// <param name="sender">PrintTaskOptionsDetails object</param>
        /// <param name="args">the event arguments containing the changed option id</param>
        async void printDetailedOptions_OptionChanged(PrintTaskOptionDetails sender, PrintTaskOptionChangedEventArgs args)
        {
            if (args.OptionId == null)
            {
                return;
            }

            string optionId = args.OptionId.ToString();

            // Handle change in Page Range Option

            if (optionId == "PageRange")
            {
                IPrintOptionDetails pageRange = sender.Options[optionId];
                string pageRangeValue         = pageRange.Value.ToString();

                selectionMode = false;

                switch (pageRangeValue)
                {
                case "PrintRange":
                    // Add PageRangeEdit custom option to the option list
                    sender.DisplayedOptions.Add("PageRangeEdit");
                    pageRangeEditVisible = true;
                    await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                                              () =>
                    {
                        ShowContent(null);
                    });

                    break;

                case "PrintSelection":
                {
                    await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                                              () =>
                        {
                            ScenarioOutput5 outputContent = (ScenarioOutput5)rootPage.OutputFrame.Content;
                            ShowContent(outputContent.SelectedText);
                        });

                    RemovePageRangeEdit(sender);
                }
                break;

                default:
                    await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                                              () =>
                    {
                        ShowContent(null);
                    });

                    RemovePageRangeEdit(sender);
                    break;
                }

                Refresh();
            }
            else if (optionId == "PageRangeEdit")
            {
                IPrintOptionDetails pageRange = sender.Options[optionId];
                // Expected range format (p1,p2...)*, (p3-p9)* ...
                if (!Regex.IsMatch(pageRange.Value.ToString(), @"^\s*\d+\s*(\-\s*\d+\s*)?(\,\s*\d+\s*(\-\s*\d+\s*)?)*$"))
                {
                    pageRange.ErrorText = "Invalid Page Range (eg: 1-3, 5)";
                }
                else
                {
                    pageRange.ErrorText = string.Empty;
                    try
                    {
                        GetPagesInRange(pageRange.Value.ToString());
                        Refresh();
                    }
                    catch (InvalidPageException ipex)
                    {
                        pageRange.ErrorText = ipex.Message;
                    }
                }
            }
        }