/// <summary>
        /// To ensure there is no memory leak, a new CustomDialog is added to and removed from the visual tree.
        /// Each step waits for it to load before continuing.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CustomDialogTestForMemoryLeak(object sender, RoutedEventArgs e)
        {
            var customDialog = new CustomDialog();

            ObjectTracker.Track(customDialog);

            var childGrid = Frame.Descendants<Grid>().FirstOrDefault() as Grid;
            if (childGrid != null)
            {
                customDialog.Loaded += (o, args) =>
                {
                    childGrid.Children.Remove(customDialog);
                };

                customDialog.Unloaded += (o, args) =>
                {
                    CheckDialogHasBeenGarbageCollected();
                };

                childGrid.Children.Add(customDialog);
            }
        }