在 XAML Designer 中找不到 DataContext class(虽然一切看起来都很好)

DataContext class not found in XAML Designer (while everything looks fine)

我正在尝试通过

在 XAML 文件中设置我的数据上下文
<Window x:Class="LocationScout.SettingsDeleteWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ViewModel="clr-namespace:LocationScout.ViewModel"
    mc:Ignorable="d"
    Title="Delete" Height="315" Width="350" 
    WindowStartupLocation="CenterScreen">

<Window.DataContext>
    <ViewModel:SettingsDeleteDisplayItem/>
</Window.DataContext>

但是 XAML 编辑器显示错误 "The name "SettingsDeleteDisplayItem" does not exist in the namespace "clr-namespace:LocationScout.ViewModel".

视图模型 class 对我来说很好:

namespace LocationScout.ViewModel
{
    public class SettingsDeleteDisplayItem : BaseObservableObject
    {
         private long _countryAreaCountToDelete;

         public long CountryAreaCountToDelete
         {
            get => _countryAreaCountToDelete;
            set
            {
                _countryAreaCountToDelete = value;
                OnPropertyChanged();
            }
        }
    }
}

构建解决方案工作正常,没有错误。任何想法?非常感谢。

根据@RobertHarvey 在评论中的建议,我更改为小写并重新启动 Visual Studio:

try changing ViewModel to lower case, as in xmlns:viewModel.

The reason this might have been an issue is because ViewModel (in upper case) appears in your namespace declarations.

现在可以了。

只是重建解决方案并没有帮助(我之前尝试过)。