WPF WindowsFormsHost sizing


I wanted to wrap a windows forms control in a wpf UserControl

<UserControl x:Class="MVVMLibrary.ReportViewer"
    Height="Auto" Width="Auto">
        <WindowsFormsHost Name="Host">

Notice that Height and Width are auto.

When I have it in a stackpanel or grid control it sets its height to 0 and basically disappears. The user is then required to resize the window(which shrunk because the usercontrol said I don't need no space, thanks). When the user resizes it stretches to whatever the user specifies.

So my question is what did I do wrong? How do I make my usercontrol take all the space available instead of not asking for any?

Best Solution

I find a better answer.

Use a dockPanel with LastChildFill=true and then put inside the WindowsFormsHost with Horizontal and Vertical Alignement to Strech, and of course the WindowsForms control have to fill.

<DockPanel LastChildFill="true">
    <WindowsFormsHost HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <Panel Dock=Fill />