XAML 参考 System.Windows.Controls.BooleanToVisibilityConverter

XAML reference to System.Windows.Controls.BooleanToVisibilityConverter

在我的 WPF 应用程序中,针对 .NET Core 3.1,我正在尝试使用内置的 System.Windows.Controls.BoolToVisibilityConverter

我想我已经为 XAML 参考查找了正确的语法。

xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"

但是我得到一个编译错误:

'System.Windows.Controls' was not found. Verify that you are not missing an assembly reference. Also, verify that your project and all referenced assemblies have been built.

可能是什么问题?

如果您查看此处的文档:

https://docs.microsoft.com/en-us/dotnet/api/system.windows.controls.booleantovisibilityconverter?view=netcore-3.1

它不在您使用的 dll 中。

命名空间: System.Windows.Controls

组装: PresentationFramework.dll

更改程序集。

    Title="MainWindow" Height="450" Width="800"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=PresentationFramework"
    >
<Window.Resources>
    <controls:BooleanToVisibilityConverter x:Key="boolConv"/>
</Window.Resources>