I can't get my UWP dialogs to exceed some fixed width. This app has been in production a few years, but after this last update, the dialogs are all some strange fixed width. I am using MVVM light and did just update to 5.4.1 but I am just calling dialog objects subclassed from ContentDialog. As I mentioned, this has been working just fine for 1.5 years or so, not sure why it just stopped working. Any help would be greatly appreciated. Thanks.
xaml code follows:
SecondaryButtonText="Cancel"
PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
SecondaryButtonClick="ContentDialog_SecondaryButtonClick"
Width="Auto"
MinWidth="1000"
Opened="ContentDialog_Opened"
Closed="ContentDialog_Closed"
DataContext="{Binding Source={StaticResource ViewModelLocator}, Path=ClockDialog}">
<Grid HorizontalAlignment="Stretch" MinWidth="900">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.3*"/>
<ColumnDefinition Width="4*" MinWidth="200"/>
<ColumnDefinition Width="1.3*"/>
<ColumnDefinition Width="4*" MinWidth="200"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<StackPanel Orientation="Vertical">
<TextBlock Margin="0,6" Text="Type:" Style="{StaticResource CCBlackTextBlock}" HorizontalAlignment="Right"/>
<TextBlock Margin="0,8" Text="Mfg:" Style="{StaticResource CCBlackTextBlock}" HorizontalAlignment="Right"/>
As noted by @Tom, I copied the MaxWidth and MaxHeight keys into the App Resources, and changed to my desired values. No other parts of the style were needed.
<Application.Resources>
<x:Double x:Key="ContentDialogMaxWidth">1200</x:Double>
<x:Double x:Key="ContentDialogMaxHeight">800</x:Double>
The default Style for ContentDialog imposes a MaxHeight of 184 and MaxWidth of 548: https://msdn.microsoft.com/en-us/library/windows/apps/mt299120.aspx
Perhaps this was added or changed in the update like you suspect. To override the style properties try something like:
<Grid Name="MyContainer">
<Grid.Resources>
<Style TargetType="ContentDialog" x:Key="largeDialaog">
<Setter Property="MaxHeight" Value="720" />
<Setter Property="MaxWidth" Value="1280" />
</Style>
</Grid.Resources>
<ContentDialog Style="{StaticResource largeDialog}">
<!--your content goes here-->
</ContentDialog>
</Grid>
Based on the previous response, I started looking at the style for ContentDialog. I could not find a default style using blend, so just decided to create my own. All I did was copy the style posted here Documented style for ContentDialog to my own style library and then applied it to all my ContentDialog screens. That did the trick and I am back in business. I suspect that something is missing from the latest VS update I applied just a few days ago.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With