Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WPF WindowsFormsHost VS2008工具箱已使所有Windows窗体控件变灰_Wpf_Visual Studio 2008_Toolbox_Windowsformshost - Fatal编程技术网

WPF WindowsFormsHost VS2008工具箱已使所有Windows窗体控件变灰

WPF WindowsFormsHost VS2008工具箱已使所有Windows窗体控件变灰,wpf,visual-studio-2008,toolbox,windowsformshost,Wpf,Visual Studio 2008,Toolbox,Windowsformshost,我正在尝试在WPF应用程序中使用WindowsFormsHost,以便使用一些Windows窗体组件 <Grid> <WindowsFormsHost> </WindowsFormsHost> </Grid> 这一切都可以正常工作,没有错误,但当我从VS2008的工具箱中拖动Windows窗体组件时,它们都变灰了。在某种程度上,这是有意义的,因为只有WPF组件可用。但是如果Windows窗体组件全部变灰且不可用,如何将其放到

我正在尝试在WPF应用程序中使用WindowsFormsHost,以便使用一些Windows窗体组件

<Grid>
    <WindowsFormsHost>

    </WindowsFormsHost>
</Grid>


这一切都可以正常工作,没有错误,但当我从VS2008的工具箱中拖动Windows窗体组件时,它们都变灰了。在某种程度上,这是有意义的,因为只有WPF组件可用。但是如果Windows窗体组件全部变灰且不可用,如何将其放到Windows窗体上?

我认为WPF designer不支持Windows窗体组件。您需要在XAML或代码中指定这些。如何将WinForms按钮添加到WPF应用程序的简单示例。请注意,按钮在设计图面上不可见

<Window x:Class="DataTemplateBind.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
    Title="Window1" Height="300" Width="300">

    <WindowsFormsHost Height="200" Name="windowsFormsHost1" Width="258" >
        <forms:Button Text="Waaa :("></forms:Button>
    </WindowsFormsHost>
</Window>


请注意添加的
xmlns:forms
名称空间,默认情况下不存在该名称空间。

谢谢Mikko,这样做了。我在漫长的一天结束时,挫折感开始袭来!