question

PallaviGayathri-9735 avatar image
0 Votes"
PallaviGayathri-9735 asked HuiLiu-MSFT answered

DockPanel inside a Usercontrol does not resize when maximised thw window

I have a usercontrol with a dockpanel with a button which is docked to bottom and grid docked to top. On maximize window, the grid docked to top is not using the whole space.
How to make the Grid on top to use the space when window is maximized?

dotnet-wpf-xaml
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

HuiLiu-MSFT avatar image
0 Votes"
HuiLiu-MSFT answered

The last child element of the DockPanel always fills the remaining space. When the window is maximized, you set a fixed width and height for the Grid and it will not resize. When the window is maximized, you could try to use the grid to resize in the UserControl instead of the DockPanel. The code is shown below, if you have any questions, please let me know.

 <Grid Background="AliceBlue"   >
         <Grid.RowDefinitions>
             <RowDefinition Height="10"/>
             <RowDefinition Height="8*"/>
             <RowDefinition Height="2*"/>
         </Grid.RowDefinitions>
         <TextBlock Background="Pink"/>
         <Grid Grid.Row="1" Background="LightGray">
                
         </Grid>
         <Button Grid.Row="2" Background="Blue"   Content="click"/>
     </Grid>

If the answer is the right solution, please click Accept Answer and kindly upvote it. If you have extra questions about this answer, please click Comment. 
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.