Reputation: 934
I have a really complex setup here. Somewhere in my code I have a WindowsFormsHost
and the content (Child) of it is set to what comes out of a DLL. I only give a bitmap to a dll and say: Give me the UserControl
(Windows.Forms) and put it inside my WindowsFormsHost
.
After that, everything works fine as intended, except that I cannot resize the Window
and the content resizes with it. Normally I would use a ViewBox
for it, but I guess, because the WindowsFormsHost
is drawn by GDI+
, it ignores the auto resizing of the ViewBox
.
If that is true, I could use a completely different approach. I already tried it with a DockPanel
but couldn't get it to work. It seems as would the WindowsFormsHost
itself resize but the content of it stays at the same size as it was drawn initially.
Has someone an idea?
Important parts of the code:
Window:
<Viewbox>
<Border BorderBrush="Black" BorderThickness="1">
<ContentControl Name="ContentUserControl" Content="{Binding DifferentControl}"
DataContext="{Binding ViewModel}" />
</Border>
</Viewbox>
UserControl:
<WindowsFormsHost x:Name="FormsHost" Grid.Row="1" />
Somewhere in the code:
mMyWindow.MyUserControl.FormsHost.Child = new ImageControl(externalDllInstance);
ImageControl:
public class ImageControl : System.Windows.Forms.UserControl
{
... normal constructor, an override for the OnPaint and few more properties, nothing important.
... The external dll (written in C++) instance does the rest.
... It is some kind of black box to me, but could be changed if it would help.
}
Upvotes: 1
Views: 138