Created Bindable WindowsFormsHost, but child update is not being reflected to control

前端 未结 1 839
北荒
北荒 2021-01-18 00:50

I created ran into a problem where i want to bind a control to a windowsFormsHost control. But as we all know, the Child property is not a DP, so i created

相关标签:
1条回答
  • 2021-01-18 01:10

    Instead of creating a wrapper you could wrap the WindowsFormsHost in a ContentControl and set its Content property via a binding. That way you avoid the issue with the WindowsFormsHosts Child property not being a dependency property.

    Something like this in XAML:

    <ContentControl Content="{Binding MyWindowsFormsHost}" />
    

    ..and this in your code-behind:

    public WindowsFormsHost MyWindowsFormsHost
    {   
        get { return new WindowsFormsHost(){Child=myWinformsControl}; }   
    }
    
    0 讨论(0)
提交回复
热议问题