-2

I'm trying to make bool to Visibility converter in a .NET Standard 2.0 Class Library. So I made my class, and when I try to add reference to System.Windows.Data I got this message:

Then I cliked using System.Windows.Data (from PresentationFramework).

Using System.Windows.Data (from PresentationFramework)

It seems to be stuck here

Visual Studio hanging when importing System.Windows.Data

I waited for some minutes but nothing changed.

thatguy
  • 21,059
  • 6
  • 30
  • 40
edwardz123
  • 21
  • 7

2 Answers2

1

You need to add the reference to your project.

  1. Right click on References in the SOlution Explorer
  2. Select Add Reference
  3. Select the .NET tab on the left, and find "System.Windows.Data" in the list of assemblies
  4. Check it and select Add Reference
Niels
  • 48,601
  • 4
  • 62
  • 81
  • Its netstandard2.0 class library. [this may be the solution](https://github.com/dotnet/standard/issues/536) – edwardz123 Feb 02 '21 at 18:57
0

WPF is not available in .NET Standard. This means that you cannot add a reference to any of the related assemblies like PresentationFramework and you cannot use System.Windows.Data.

You have to create a class library with a framework that supports WPF, these are:

  • .NET Framework >=3.0
  • .NET Core >= 3.0
  • .NET >= 5.0
thatguy
  • 21,059
  • 6
  • 30
  • 40
  • You also need to use a WPF project type. It will not work if you try to include it into a .Net class library, but it will in a WPF program and probably (not tested) in a .NET WPF class library. Probably from the point of view of separation of concerns, you should not try using this in your core libraries, because you primarily need it to support UI features. So you can create a separate Model in the UI layer, that will do the conversion for you. – RudolfJan May 20 '21 at 08:16