【发布时间】:2017-02-21 07:01:08
【问题描述】:
我正在开发一个 MVVM 应用程序
我想在我的应用程序中绑定到 WindowsFormHost。但 WindowsFormHost 不是依赖属性。
所以在我的视图模型中创建一个新的 WindowsFormHost 并将其绑定到 contentcontrol 的子项。但是我在运行程序时遇到了两次调用的绑定。
有什么建议吗??
我的 XAML
<Window x:Class="Demo.View.area"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Demo.View"
mc:Ignorable="d"
Title="area" Height="300" Width="300">
<ContentControl Content="{Binding myWindow}" />
</Window>
我的 viewModel.cs 包含以下实现
public WindowsFormsHost myWindow
{
get
{
return new WindowsFormsHost() { Child = newWindow };
//newWindow defined in another place
}
}
【问题讨论】: