Search code examples
.netxamlgridviewbox

How to stretch Grid within a Viewbox


I would like to stretch Grid within a Viewbox. The code I have god does not work properly. Any clue?

 <Viewbox HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
         <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
            </Grid.RowDefinitions>
 </Grid>
</Viewbox>

enter image description here


Solution

  • Change strech property of Viewbox to Fill like below.

    < Viewbox Stretch="Fill" >