<ContentDialog
x:Class="SizableContentDialog.ContentDialog3"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SizableContentDialog"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="TITLE"
PrimaryButtonText="Button1"
SecondaryButtonText="Button2"
PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
SecondaryButtonClick="ContentDialog_SecondaryButtonClick">
<Grid x:Name="MyGrid">
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top">Small Text</TextBlock>
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Bottom">Small Text</TextBlock>
</Grid>
</ContentDialog>
using System;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Shapes;
namespace ResizeContentDialogUtil
{
public static class ResizeContentDialogUtil
{
private static T find<T>(DependencyObject root, Func<T, bool> checker = null) where T : DependencyObject
{
if (root == null) return null;
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(root); i++)
{
var r = VisualTreeHelper.GetChild(root, i);
var r1 = r as T;
if (r1 != null)
{
if (checker == null) return r1;
if (checker(r1)) return r1;
}
var r2 = find<T>(r, checker);
if (r2 != null) return r2;
}
return null;
}
public static void FixContentDialogForConstructor(ContentDialog dialog)
{
dialog.MaxHeight = double.PositiveInfinity;
dialog.MaxWidth = double.PositiveInfinity;
dialog.Loaded += (sender, e) =>
{
Grid mainGrid = (Grid)dialog.Content;
var largeRect = new Rectangle();
largeRect.Width = 30000;
largeRect.Height = 30000;
largeRect.Fill = new SolidColorBrush(Colors.Transparent);
mainGrid.Children.Insert(0, largeRect);
};
}
}
}
Insert call to FixContentDialogForConstructor method in constructor in a class that inherited from ContentDialog.
This is a example.