WPF “not a valid value for property” error for attached property even though it works as expected

WPF “not a valid value for property” error for attached property even though it works as expected

I have a TextBox with an attached property on it, and Visual Studio gives me an error saying that the property value is not valid, even though it is in fact valid.

I have a TextBox with an attached property on it, and Visual Studio gives me an error saying that the property value is not valid, even though it is in fact valid.

Here's the TextBox:

<TextBox 
    HorizontalAlignment="Stretch" 
    VerticalAlignment="Top" 
    Width="Auto" 
    styleExtensions:TextBoxExtension.BorderStyle="None"/>

And this is the AttachedProperty:

public enum BorderStyle
{
    Rounded,
    BottomOnly,
    None
}

public static DependencyProperty BorderStyleProperty = DependencyProperty.RegisterAttached( "BorderStyle", typeof(BorderStyle), typeof(TextBoxExtension));

The GetBorderStyle and SetBorderStyle methods are also present, and since they do nothing special, I didn't paste them here.

When I rut it, the program works as expected, all three values for BorderStyle do what they're supposed to (they trigger different changes in a Style) and even the visual xaml editor shows the changes as expected, but for some reason Visual Studio keeps giving me this pointless error for this particular TextBox:

'None' is not a valid value for property 'BorderStyle'

The error persists for all three values of the enum. The same attached property is also used somewhere else in a ControlTemplate, on a different TextBox and it doesn't trigger this error.

I've tried cleaning the solution, rebuilding it, deleting the bin and obj folders, deleting the .vs folder, but the error keeps showing up.

Am I doing something wrong here, or is Visual Studio wrong? And if so, is there a workaround to disable this specific error message?

I'm using Visual Studio 2017 15.8.8, and .NET Framework 4.7.03056

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Python in Visual Studio Code

Python in Visual Studio Code

Coding F# in Visual Studio Code with Ionide

In this post, Phillip Carter sits down with Cecil is talk about the Ionide extension for Visual Studio Code. Ionide tons of of great features for F# developers working in Visual Studio code such as autocomplete, packet integration, syntax highlighting and much more.