AppPromo.UWP.ActionDialog.ActionDialog_Opened C# (CSharp) Method

ActionDialog_Opened() private method

private ActionDialog_Opened ( ContentDialog sender, ContentDialogOpenedEventArgs args ) : void
sender ContentDialog
args ContentDialogOpenedEventArgs
return void
        private void ActionDialog_Opened(ContentDialog sender, ContentDialogOpenedEventArgs args)
        {
            // HACK: Tweak the ContentDialog to show expanded content.
            //
            // I'm really not a fan of hacks like this. They're brittle and if done wrong
            // they can actually crash apps. But unfortunately the inner template for
            // ContentDialog is not easily changed and having the "don't remind me again"
            // check box floating up near the content looks really bad.
            //
            // Though the implementation below is brittle, at least it should not crash
            // if the default template changes and is not likely to break existing content.
            // JB - 2016-03-29

            // Try to find a parent Grid control
            FrameworkElement parent = VisualTreeHelper.GetParent(LayoutRoot) as FrameworkElement;
            var parentGrid = parent as Grid;
            while ((parent != null) && (parentGrid == null))
            {
                parent = VisualTreeHelper.GetParent(parent) as FrameworkElement;
                parentGrid = parent as Grid;
            }

            // If found
            if (parentGrid != null)
            {
                // And it has exactly two rows
                if (parentGrid.RowDefinitions.Count == 2)
                {
                    // Assume it's the right one and expand the content area (second row)
                    parentGrid.RowDefinitions[1].Height = new GridLength(1, GridUnitType.Star);
                }
            }
        }