Click here to Skip to main content
15,877,915 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi:

I have a winforms custom control that I'm attempting to host in a WindowsFormControl.
I seem be running into some issues getting the height of the control to behave correctly.

I've got a grid, that contains a StackPanel, which contains the actual embedded WindowsFormControl. I would like the WindowsFormControl's height to take up all the available height in the StackPanel.

The actual winforms custom user control's height behaves correctly as it fills the height area available within the WindowsFormHost.

I'm not entirely clear on what's going on.

Here is XAML fragment containing the control definitions:
XML
<Grid  Grid.Row="0" removed="#7A66BAD2">
           <Grid.RowDefinitions>
               <RowDefinition Height="9*"/>
               <RowDefinition Height="1*"/>
           </Grid.RowDefinitions>

           <StackPanel Grid.Row="0" >

               <WindowsFormsHost Name="RPIWinformsHost" Height="700"
                                 removed="Orange"
                                 HorizontalAlignment="Stretch"
                                 VerticalAlignment="Stretch"
                                 Margin="30,10,30,10">
                   <rpiRTFControl:RPIReportDesignControl Name="RPIRTFControl" />

               </WindowsFormsHost>

           </StackPanel>

           <Border BorderBrush="#CCCCFF" Grid.Row="1" BorderThickness="6"
                   HorizontalAlignment="Stretch" Margin="30,0,30,0">
               <StackPanel Name="spCommands"
                   Orientation="Horizontal">

                   <Button Name="btnTest" Content="Test" Height="25" Width="134"
               FontSize="13" FontWeight="Bold"
               Margin="10,0,10,0"
               Click="btnTest_Click" />

                </StackPanel>
           </Border>

       </Grid>

What is the correct technique/trick for having this behave correctly?

Thanks,
JohnB
Posted
Updated 27-Apr-13 1:00am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900