UWP ContentDialog set Content dimension to the app window size

771 Views Asked by At

I have a ContentDialog with a WebView inside a Grid:

<ContentDialog
x:Class="Name of Class"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FullSizeDesired="True"
Visibility="{x:Bind Vm.IsBrowserVisible, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}"
Title="{x:Bind Vm.Title}"
PrimaryButtonText=""
SecondaryButtonText="{x:Bind Vm.CancelButtonLabel}"
SecondaryButtonCommand="{x:Bind Vm.SecondaryButtonCommand, Mode=OneWay}">

<Grid>
    <WebView x:Name="SamlWebView"
             Visibility="{x:Bind Vm.IsBrowserVisible, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}"
             HorizontalAlignment="Stretch"
             VerticalAlignment="Stretch"
             ScrollViewer.HorizontalScrollMode="Enabled"
             ScrollViewer.HorizontalScrollBarVisibility="Visible"/>
</Grid>

What I would like is, that the ContentDialog expands all the way to the current app windows size.

I currently get the corrent hight, however, the width won't expand to the parent window borders:

enter image description here

Any idea what I have to change?

I have overriden the ContentDialogMaxWidth to 2000 for testing puroses, but It didn't changed anything.

If I manually set the width of the Grid to say 1500 it works but i dont want to hardcode it; it should deal correctly if i resize the window.

thanks.

1

There are 1 best solutions below

0
On BEST ANSWER

UWP ContentDialog set Content dimension to the app window size

The problem is that you have not specified the ContentDialogMinWidth for contentdialog, so it will render as default <x:Double x:Key="ContentDialogMinWidth">320</x:Double>. You could override the default one like the following to make it display the full webview content.

<Application.Resources>
    <ResourceDictionary>
        <x:Double x:Key="ContentDialogMinWidth">1500</x:Double>
        <x:Double x:Key="ContentDialogMaxWidth">2000</x:Double>
        <x:Double x:Key="ContentDialogMinHeight">800</x:Double>
        <x:Double x:Key="ContentDialogMaxHeight">2000</x:Double>
    </ResourceDictionary>
</Application.Resources>