本文介绍了带有.net core 3.0的ICollectionView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将项目从经典的.net迁移到.net core 3.0.我在ViewModel ICollectionView接口中使用它,但.net core 3.0框架无法识别它.

I'm migrating my project from classic .net to .net core 3.0.I use in my viewmodel ICollectionView interface and it is not recognized in .net core 3.0 framework.

我添加了几个nuget软件包以尝试使其正常运行,但是没有运气.

I added several nuget packages to attempt to make it work, but with no luck.

Microsoft声称System.ComponentModel定义了icollectionview( https://docs.microsoft.com/zh-CN/dotnet/api/system.componentmodel.icollectionview?view=netcore-3.0 ),但找不到.我还尝试包括Windowsbase,但也找不到.

Microsoft claims System.ComponentModel defines icollectionview (https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.icollectionview?view=netcore-3.0), but it is not found.I also tried to include windowsbase, but it's not found either.

我的环境有问题吗?我错过了什么吗?

Is my environment faulty ? Did I miss something ?

感谢您的帮助.

这是一个可在.netcore3项目下编译的小类:

Here is a small class to compile under a .netcore3 project:

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Hello World!");
        ICollectionView col =new CollectionViewSource().View;
        col.Filter = null;
        col.Refresh();
    }
}

感谢ALFA for Microsoft.Windows.SDK.Contracts在.net核心上提供ICollectionView接口,但不幸的是,它还不完整:未实现过滤器和刷新.

Thanks to ALFA for Microsoft.Windows.SDK.Contracts which offer an ICollectionView interface on .net core, but unfortunatly, it is not complete: Filter and refresh are not implemented.

推荐答案

您需要从以下位置编辑项目文件 YourProjectName.csproj :

You need to edit your project file YourProjectName.csproj from this:

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

<PropertyGroup>
   <TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>

对此:

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

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

对我有帮助.

这篇关于带有.net core 3.0的ICollectionView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 03:22