MVVM 응용 프로그램을 만들고 있습니다. 내 모델에서WindowsFormsHost 하위 속성 바인딩
는 나는 보기에 표시되고있는 System.Windows.Forms.Panel에 핸들이 필요합니다. 가 뷰 모델에서이 패널를 만든 다음 한쪽에서에 내 생각은 - 그것은에보기를 결합 , 다른 측면에서, 모델에 그 핸들을 전달합니다.
가 나는 WindowsFormsHost 컨트롤이있어 :
<Page x:Class="Test.Views.RenderPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WinForms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Test.Views"
mc:Ignorable="d"
d:DesignHeight="800" d:DesignWidth="1200"
Title="Page1">
<DockPanel>
<WindowsFormsHost x:Name="winformsHost" Child="{Binding RenderPanel}"/>
</DockPanel>
</Page>
을 그리고 나는 그것이 뷰 모델에서 제공하는 내 RenderPanel와 아이 속성의 결합하고자하는
public ObservableObject<System.Windows.Forms.Panel> RenderPanel { get; private set; }
public VideoRecorderViewModel()
{
RenderPanel = new System.Windows.Forms.Panel(); //Bind it here
var model = new Model (RenderPanel.Handle); pass it to the model
}
그러나, 나는 없다는 오류를 얻고있다 :
System.Windows.Markup.XamlParseException:
A 'Binding' cannot be set on the 'Child' property of type 'WindowsFormsHost'.
A 'Binding' can only be set on a DependencyProperty of a DependencyObject.
해결 방법?
이 답변은 당신을 도울 것입니다 : http://stackoverflow.com/questions/11435781/a-binding-can-only-be-set-on-a-dependencyproperty-of-a- dependencyobject – alessalessio