C# Visual Studio-WPF-引用未正确添加

C# Visual Studio-WPF-引用未正确添加,c#,wpf,xaml,visual-studio-2013,C#,Wpf,Xaml,Visual Studio 2013,我看过过去关于这个问题的问题,但没有结果 我刚刚在VS2013中创建了一个新的WPF项目。我转到添加引用,然后选择System.Windows.Form。它补充道。太好了 但是,工具箱中的相应工具仍然是灰色的。是,自动更新工具箱已打开。我已经展示了一切。我已重新启动VS并重建了我的解决方案。我使用System.Windows.Forms添加了到我的MainWindow.xaml.cs文件 在这里,我只有基本的代码,因为这是一个全新的项目,我还没有接触过 我错过了什么??我已尝试将.dll文件拖到

我看过过去关于这个问题的问题,但没有结果

我刚刚在VS2013中创建了一个新的WPF项目。我转到添加引用,然后选择System.Windows.Form。它补充道。太好了

但是,工具箱中的相应工具仍然是灰色的。是,自动更新工具箱已打开。我已经展示了一切。我已重新启动VS并重建了我的解决方案。我使用System.Windows.Forms添加了
到我的MainWindow.xaml.cs文件

在这里,我只有基本的代码,因为这是一个全新的项目,我还没有接触过

我错过了什么??我已尝试将.dll文件拖到工具箱中,但工具仍呈灰色。有没有我遗漏的代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Forms;

namespace sub20tool3
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
使用System.Windows;
使用System.Windows.Controls;
使用System.Windows.Data;
使用System.Windows.Documents;
使用System.Windows.Input;
使用System.Windows.Media;
使用System.Windows.Media.Imaging;
使用System.Windows.Navigation;
使用System.Windows.Shapes;
使用System.Windows.Forms;
命名空间sub20tool3
{
/// 
///MainWindow.xaml的交互逻辑
/// 
公共部分类主窗口:窗口
{
公共主窗口()
{
初始化组件();
}
}
}
以及:


您需要一个WindowsFormHost元素来保存WPF项目中的winforms控件。WindowsFormHost还需要对WindowsFormIntegration的引用

下面是一个关于如何使用它们的好教程:


您需要一个WindowsFormHost元素来保存WPF项目中的winforms控件。WindowsFormHost还需要对WindowsFormIntegration的引用

下面是一个关于如何使用它们的好教程:



您不能直接在WPF中托管Winforms控件。您需要使用WindowsFormHost在wpf中添加Winforms控件。另外,请参阅简单教程,如果您只是想在WPF页面上放置标准控件,请使用这些控件的WPF版本,而不是WinForms版本。您不能在WPF中直接宿主WinForms控件。您需要使用WindowsFormHost在wpf中添加Winforms控件。另外,请参阅简单教程,如果您只是想在WPF页面上放置标准控件,请使用这些控件的WPF版本,而不是WinForms版本。
<Window x:Class="sub20tool3.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sys="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
        xmlns:local="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
        Title="MainWindow" Height="350" Width="525">
    <Grid>

    </Grid>
</Window>
<Window x:Class="WpfTutorialSamples.Misc_controls.WindowsFormsHostSample"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
        Title="WindowsFormsHostSample" Height="350" Width="450">
    <Grid>
        <WindowsFormsHost Name="wfhSample">
            <WindowsFormsHost.Child>
                <wf:WebBrowser DocumentTitleChanged="wbWinForms_DocumentTitleChanged" />
            </WindowsFormsHost.Child>
        </WindowsFormsHost>
    </Grid>
</Window>