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

问题描述 投票:0回答:1

我看到错误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类?

.net-core-3.0
1个回答
0
投票

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

问候

© www.soinside.com 2019 - 2024. All rights reserved.