错误MC3074:XML名称空间“ http://schemas.microsoft.com/winfx/2006/xaml/presentation”中不存在标签“ WindowsFormsHost”

时间:2019-11-06 20:35:29

标签: .net-core-3.0

我看到错误MC3074:XML名称空间'http://schemas.microsoft.com/winfx/2006/xaml/presentation'中不存在标签'WindowsFormsHost'。

我的以下代码: Wpf.csproj

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <UseWPF>true</UseWPF>
  </PropertyGroup>

</Project>

和Window1.xaml

<Window x:Class="WpfCs.Window1"
    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="WPF Demo" Height="500" Width="1000" Icon="/WpfCs;component/App.ico">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="250" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <ToolBarTray Background="White" Grid.Row="0" Grid.ColumnSpan="2">
            <ToolBar Band="1" BandIndex="1">
                <Button Name="tbbOpen" Content="Open" Click="tbbOpen_Click">
                </Button>
                <Separator/>
                <Button Name="tbbPlay" Content="Play" Click="tbbPlay_Click">
                </Button>
                <Separator/>
                <Button Name="tbbStop" Content="Stop" Click="tbbStop_Click">
                </Button>
            </ToolBar>
        </ToolBarTray>

        <WindowsFormsHost Name="wfh" Grid.Row="1" Grid.Column="1" >
        </WindowsFormsHost>

    </Grid>
</Window>

此代码在.Net Framework下有效。 如何在.Net Core 3.0应用程序中使用WindowsFormsHost类?

1 个答案:

答案 0 :(得分:0)

您收到错误: 标签“ WindowsFormsHost”在XML名称空间中不存在,因为标签WindowsFormsHost尚未在XML名称空间中解释。