Error Xaml namespace

2019-09-17 05:47发布

问题:

I am following a tutorial to implement a value converter. I receive an error for this code:

public class BooleanToVisibilityConverter : IValueConverter
{
    //
}

<Application
x:Class="TestApp10.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestApp10"
RequestedTheme="Light">
<Application.Resources>
    <local:BooleanToVisibilityConverter x:Key="TrueToVisibleConverter" />
    <local:BooleanToVisibilityConverter x:Key="FalseToVisibleConverter" IsReversed="True" />
</Application.Resources>

I get an error

The name "BooleanToVisibilityConverter" does not exist in the namespace "using:TestApp10"

The function is defined in the App.xaml.cs file.

Thank you.

回答1:

This seems to be an intellisense error in XAML Designer. Please make sure you have implemented your BooleanToVisibilityConverter correctly. Then you can try with following steps to fix this error.

  1. Open your project in File Explorer, delete bin and obj folder
  2. In Visual Studio, right-click your Solution, and select Clean.
  3. Right-click your Solution, and select Rebuild.

After this, your error should be gone. If you still get this error, you can try to reopen your project in Visual Studio.