문제

I'm attempting to place a Winforms panel within my WPF UserControl, with the following code;

<WindowsFormsHost Grid.Row="3">
    <WinForms:Panel>
        <WinForms:TableLayoutPanel x:Name="myLayoutPanel" />
    </WinForms:Panel>
</WindowsFormsHost>

Error:

The type 'Panel' does not support direct content.

I'm will then then initialise the TableLayoutPanel panel within C# code. Any ideas how I can workaround this error?

도움이 되었습니까?

해결책

the Windows.Forms Panel Container is called Controls. You should be able to add it by doing something like this: If it were me I would just create a Winforms UserControl and add that to the WinFormsHost instead.

<WindowsFormsHost Height="100" HorizontalAlignment="Left" Margin="10,108,0,0" Name="windowsFormsHost1" VerticalAlignment="Top" Width="200">
    <WinForms:Panel BackColor="Red" Dock="Fill">
        <WinForms:Panel.Controls>
            <WinForms:TableLayoutPanel x:Name="myLayoutPanel"/>
        </WinForms:Panel.Controls>
    </WinForms:Panel>
</WindowsFormsHost>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top