/// <summary>
        /// This is the click handler for the 'Display' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Display_Click(object sender, RoutedEventArgs e)
        {
            // This scenario uses language tags with unicode extensions to construct and use the various 
            // formatters and NumeralSystemTranslator in Windows.Globalization.NumberFormatting to format numbers 

            // Keep results of the scenario in a StringBuilder
            StringBuilder results = new StringBuilder();

            // Create number to format.
            double randomNumber = (new Random().NextDouble() * 100000);
            results.AppendLine("Random number used by formatters: " + randomNumber);
            // Create a string to translate
            String stringToTranslate = "These are the 10 digits of a numeral system: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9";
            results.AppendLine("String used by NumeralSystemTranslater: " + stringToTranslate);
            // Create the rounder and set its increment to 0.01
            IncrementNumberRounder rounder = new Windows.Globalization.NumberFormatting.IncrementNumberRounder();
            rounder.Increment = 0.001;
            results.AppendLine("CurrencyFormatter will be using Euro symbol and all formatters rounding to 0.001 increments");
            results.AppendLine();

            // The list of language tags with unicode extensions we want to test
            String[] languages = new[] { "de-DE-u-nu-telu-ca-buddist-co-phonebk-cu-usd", "ja-jp-u-nu-arab"};
            
            // Create the various formatters, now using the language list with unicode extensions            
            results.AppendLine("Creating formatters using following languages in the language list:");
            foreach(String language in languages)
            {
                results.AppendLine("\t" + language);
            }
            results.AppendLine();

            // Create the various formatters.
            DecimalFormatter decimalFormatter = new DecimalFormatter(languages, "ZZ");
            decimalFormatter.NumberRounder = rounder; decimalFormatter.FractionDigits = 2;
            CurrencyFormatter currencyFormatter = new CurrencyFormatter(CurrencyIdentifiers.EUR, languages, "ZZ");
            currencyFormatter.NumberRounder = rounder; currencyFormatter.FractionDigits = 2;
            PercentFormatter percentFormatter = new PercentFormatter(languages, "ZZ");
            percentFormatter.NumberRounder = rounder; percentFormatter.FractionDigits = 2;
            PermilleFormatter permilleFormatter = new PermilleFormatter(languages, "ZZ");
            permilleFormatter.NumberRounder = rounder; permilleFormatter.FractionDigits = 2;
            NumeralSystemTranslator numeralTranslator = new NumeralSystemTranslator(languages);

            results.AppendLine("Using resolved language  " + decimalFormatter.ResolvedLanguage + "  : (note that all extension tags other than nu are ignored)");
            // Format using formatters and translate using NumeralSystemTranslator.
            results.AppendLine("Decimal Formatted:   " + decimalFormatter.Format(randomNumber));
            results.AppendLine("Currency formatted:   " + currencyFormatter.Format(randomNumber));
            results.AppendLine("Percent formatted:   " + percentFormatter.Format(randomNumber));
            results.AppendLine("Permille formatted:   " + permilleFormatter.Format(randomNumber));
            results.AppendLine("NumeralTranslator translated:   " + numeralTranslator.TranslateNumerals(stringToTranslate));
            results.AppendLine();

            // Display the results
            OutputTextBlock.Text = results.ToString();
        }
        /// <summary>
        /// Demonstrates how to perform padding and rounding by using the DecimalFormatter class (can be any of the
        /// formatter classes in the Windows.Globalization.Numberformatting namespace) and the IncrementNumberRounder
        /// to do so.  The SignificantDigitsNumberRounder can also be used instead of the latter.
        /// </summary>
        /// <param name="roundingAlgorithm"></param>
        /// <param name="significantDigits"></param>
        /// <param name="integerDigits"></param>
        /// <param name="fractionalDigits"></param>
        string DoPaddingAndRoundingScenarios(RoundingAlgorithm roundingAlgorithm, int significantDigits, int integerDigits, int fractionalDigits)
        {
            // Create the rounder and set the rounding algorithm provided as a parameter
            IncrementNumberRounder rounder = new Windows.Globalization.NumberFormatting.IncrementNumberRounder();

            rounder.RoundingAlgorithm = roundingAlgorithm;

            // Create the formatter, set the padding properties provided as parameters and associate the rounder
            // we have just created
            DecimalFormatter formatter = new Windows.Globalization.NumberFormatting.DecimalFormatter();

            formatter.SignificantDigits = significantDigits;
            formatter.IntegerDigits     = integerDigits;
            formatter.FractionDigits    = fractionalDigits;
            formatter.NumberRounder     = rounder;

            // Stores the results
            StringBuilder results = new StringBuilder();

            // Iterate through the increments we have defined in the scenario
            double[] incrementsToRound = new double[] { 0.001, 0.01, 0.1, 1.0 };
            foreach (double incrementToRound in incrementsToRound)
            {
                // Set the increment to round to
                rounder.Increment = incrementToRound;

                // Display the properties of the scenario
                results.Append("Padding and rounding with ");
                results.Append(formatter.SignificantDigits + " significant digits, ");
                results.Append(formatter.IntegerDigits + " integer digits, ");
                results.Append(formatter.FractionDigits + " fractional digits, ");
                results.Append(rounder.Increment + " increment and ");
                results.Append(DisplayRoundingAlgorithmAsString(rounder.RoundingAlgorithm) + " rounding algorithm\n\n");

                // Iterate through the numbers to round and pad, format them and add them to the results
                double[] numbersToFormat = new double[]  { 0.1458, 1.458, 14.58, 145.8 };
                foreach (double numberToFormat in numbersToFormat)
                {
                    string formattedNumber = formatter.Format(numberToFormat);
                    results.Append("Value: " + numberToFormat + " Formatted: " + formattedNumber + "\n");
                }

                // Add a carriage return at the end of the scenario for readability
                results.AppendLine();
            }

            return(results.ToString());
        }
        /// <summary>
        /// Shows how to do number rounding using the IncrementNumberRounding class.
        ///</summary>
        ///<param name="roundingAlgorithm"></param>
        private string DoIncrementRoundingScenarios(RoundingAlgorithm roundingAlgorithm)
        {
            // Create the rounder and set the rounding algorithm provided as a parameter
            IncrementNumberRounder rounder = new Windows.Globalization.NumberFormatting.IncrementNumberRounder();

            rounder.RoundingAlgorithm = roundingAlgorithm;

            // Formatter to display the rounded value.  It is recommended to use the increment number
            // rounder within a formatter object to avoid precision issues when displaying.
            DecimalFormatter formatter = new Windows.Globalization.NumberFormatting.DecimalFormatter();

            formatter.NumberRounder = rounder;

            // Stores the results
            StringBuilder results = new StringBuilder();

            // Iterate through the increments we have defined in the scenario
            double[] incrementsToRound = new double[] { 0.001, 0.01, 0.1, 1.0 };
            foreach (double incrementToRound in incrementsToRound)
            {
                // Set the significant digits to round to
                rounder.Increment = incrementToRound;

                // Display the properties of the scenario
                results.Append("Rounding with ");
                results.Append(rounder.Increment + " increment and ");
                results.Append(DisplayRoundingAlgorithmAsString(rounder.RoundingAlgorithm) + " rounding algorithm\n\n");

                // Iterate through the numbers to round and add them to the results
                double[] numbersToRound = new double[] { 0.1458, 1.458, 14.58, 145.8 };
                foreach (double numberToRound in numbersToRound)
                {
                    results.Append("Value: " + numberToRound + " Rounded: " + formatter.Format(numberToRound) + "\n");
                }

                // Add a carriage return at the end of the scenario for readability
                results.AppendLine();
            }

            return(results.ToString());
        }
        /// <summary>
        /// Shows how to do number rounding using the IncrementNumberRounding class.
        ///</summary>
        ///<param name="roundingAlgorithm"></param>
        private string DoIncrementRoundingScenarios(RoundingAlgorithm roundingAlgorithm) 
        {
            // Create the rounder and set the rounding algorithm provided as a parameter
            IncrementNumberRounder rounder = new Windows.Globalization.NumberFormatting.IncrementNumberRounder();
            rounder.RoundingAlgorithm = roundingAlgorithm;

            // Formatter to display the rounded value.  It is recommended to use the increment number
            // rounder within a formatter object to avoid precision issues when displaying.
            DecimalFormatter formatter = new Windows.Globalization.NumberFormatting.DecimalFormatter();
            formatter.NumberRounder = rounder;

            // Stores the results
            StringBuilder results = new StringBuilder();

            // Iterate through the increments we have defined in the scenario
            double[] incrementsToRound = new double[] { 0.001, 0.01, 0.1, 1.0 };
            foreach (double incrementToRound in incrementsToRound)
            {
                // Set the significant digits to round to
                rounder.Increment = incrementToRound;

                // Display the properties of the scenario
                results.Append("Rounding with ");
                results.Append(rounder.Increment + " increment and ");
                results.Append(DisplayRoundingAlgorithmAsString(rounder.RoundingAlgorithm) + " rounding algorithm\n\n");

                // Iterate through the numbers to round and add them to the results
                double[] numbersToRound = new double[] { 0.1458, 1.458, 14.58, 145.8 };
                foreach (double numberToRound in numbersToRound) 
                {
                    results.Append("Value: " + numberToRound + " Rounded: " + formatter.Format(numberToRound) + "\n");
                }

                // Add a carriage return at the end of the scenario for readability
                results.AppendLine();
            }

            return results.ToString();
        }
        /// <summary>
        /// Demonstrates how to perform padding and rounding by using the DecimalFormatter class (can be any of the 
        /// formatter classes in the Windows.Globalization.Numberformatting namespace) and the IncrementNumberRounder
        /// to do so.  The SignificantDigitsNumberRounder can also be used instead of the latter.
        /// </summary>
        /// <param name="roundingAlgorithm"></param>
        /// <param name="significantDigits"></param>
        /// <param name="integerDigits"></param>
        /// <param name="fractionalDigits"></param>
        string DoPaddingAndRoundingScenarios(RoundingAlgorithm roundingAlgorithm, int significantDigits, int integerDigits, int fractionalDigits) 
        {
            // Create the rounder and set the rounding algorithm provided as a parameter
            IncrementNumberRounder rounder = new Windows.Globalization.NumberFormatting.IncrementNumberRounder();
            rounder.RoundingAlgorithm = roundingAlgorithm;

            // Create the formatter, set the padding properties provided as parameters and associate the rounder
            // we have just created
            DecimalFormatter formatter = new Windows.Globalization.NumberFormatting.DecimalFormatter();
            formatter.SignificantDigits = significantDigits;
            formatter.IntegerDigits = integerDigits;
            formatter.FractionDigits = fractionalDigits;
            formatter.NumberRounder = rounder;

            // Stores the results
            StringBuilder results = new StringBuilder();

            // Iterate through the increments we have defined in the scenario
            double[] incrementsToRound = new double[] { 0.001, 0.01, 0.1, 1.0 };
            foreach (double incrementToRound in incrementsToRound) 
            {
                // Set the increment to round to
                rounder.Increment = incrementToRound;

                // Display the properties of the scenario
                results.Append("Padding and rounding with ");
                results.Append(formatter.SignificantDigits + " significant digits, ");
                results.Append(formatter.IntegerDigits + " integer digits, ");
                results.Append(formatter.FractionDigits + " fractional digits, ");
                results.Append(rounder.Increment + " increment and ");
                results.Append(DisplayRoundingAlgorithmAsString(rounder.RoundingAlgorithm) + " rounding algorithm\n\n");

                // Iterate through the numbers to round and pad, format them and add them to the results
                double[] numbersToFormat = new double[]  {0.1458, 1.458, 14.58, 145.8 };
                foreach (double numberToFormat in numbersToFormat) 
                {
                    string formattedNumber = formatter.Format(numberToFormat);
                    results.Append("Value: " + numberToFormat + " Formatted: " + formattedNumber + "\n");
                }

                // Add a carriage return at the end of the scenario for readability
                results.AppendLine();
            }

            return results.ToString();
        }
        /// <summary>
        /// This is the click handler for the 'Display' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Display_Click(object sender, RoutedEventArgs e)
        {
            // This scenario uses language tags with unicode extensions to construct and use the various
            // formatters and NumeralSystemTranslator in Windows.Globalization.NumberFormatting to format numbers

            // Keep results of the scenario in a StringBuilder
            StringBuilder results = new StringBuilder();

            // Create number to format.
            double randomNumber = (new Random().NextDouble() * 100000);

            results.AppendLine("Random number used by formatters: " + randomNumber);
            // Create a string to translate
            String stringToTranslate = "These are the 10 digits of a numeral system: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9";

            results.AppendLine("String used by NumeralSystemTranslater: " + stringToTranslate);
            // Create the rounder and set its increment to 0.01
            IncrementNumberRounder rounder = new Windows.Globalization.NumberFormatting.IncrementNumberRounder();

            rounder.Increment = 0.001;
            results.AppendLine("CurrencyFormatter will be using Euro symbol and all formatters rounding to 0.001 increments");
            results.AppendLine();

            // The list of language tags with unicode extensions we want to test
            String[] languages = new[] { "de-DE-u-nu-telu-ca-buddist-co-phonebk-cu-usd", "ja-jp-u-nu-arab" };

            // Create the various formatters, now using the language list with unicode extensions
            results.AppendLine("Creating formatters using following languages in the language list:");
            foreach (String language in languages)
            {
                results.AppendLine("\t" + language);
            }
            results.AppendLine();

            // Create the various formatters.
            DecimalFormatter decimalFormatter = new DecimalFormatter(languages, "ZZ");

            decimalFormatter.NumberRounder = rounder; decimalFormatter.FractionDigits = 2;
            CurrencyFormatter currencyFormatter = new CurrencyFormatter(CurrencyIdentifiers.EUR, languages, "ZZ");

            currencyFormatter.NumberRounder = rounder; currencyFormatter.FractionDigits = 2;
            PercentFormatter percentFormatter = new PercentFormatter(languages, "ZZ");

            percentFormatter.NumberRounder = rounder; percentFormatter.FractionDigits = 2;
            PermilleFormatter permilleFormatter = new PermilleFormatter(languages, "ZZ");

            permilleFormatter.NumberRounder = rounder; permilleFormatter.FractionDigits = 2;
            NumeralSystemTranslator numeralTranslator = new NumeralSystemTranslator(languages);

            results.AppendLine("Using resolved language  " + decimalFormatter.ResolvedLanguage + "  : (note that all extension tags other than nu are ignored)");
            // Format using formatters and translate using NumeralSystemTranslator.
            results.AppendLine("Decimal Formatted:   " + decimalFormatter.Format(randomNumber));
            results.AppendLine("Currency formatted:   " + currencyFormatter.Format(randomNumber));
            results.AppendLine("Percent formatted:   " + percentFormatter.Format(randomNumber));
            results.AppendLine("Permille formatted:   " + permilleFormatter.Format(randomNumber));
            results.AppendLine("NumeralTranslator translated:   " + numeralTranslator.TranslateNumerals(stringToTranslate));
            results.AppendLine();

            // Display the results
            rootPage.NotifyUser(results.ToString(), NotifyType.StatusMessage);
        }