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

wpf visual-studio

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Visual Studio 2019 v16.7 Preview 2 Available Today!

Today we are releasing 16.7 Preview 2 with new features in C++ Connection Manager, .NET Productivity, Git Productivity, and Local Process with Kubernetes.

Syncfusion Visual Studio Extensions Support .NET 5.0 Preview 6

On June 25, 2020, Microsoft announced .NET 5.0 Preview 6. We already promised to provide support for.NET 5.0 for web and desktop platforms in this blog. Now, we at Syncfusion happily announce .NET 5.0 Preview 6 support in the Syncfusion Visual Studio extensions for the following platforms: Blazor WP

Python в Visual Studio Code

We are pleased to announce that the July release of the Python extension is now available for Visual Studio Code. You can download the Python extension from the Marketplace, or install it directly from the extension gallery in Visual Studio Code. If you already have the Python extension installed, you can also get the latest update by restarting Visual Studio Code. You can read more about Python support in Visual Studio Code in the documentation .

Visual Studio Installerでサービスのインストール方法について|

実現したいことVisual Studio Installerでインストーラーを作成しています。既存のexeをサービスにインストールしたいです。exeは単体でインストールすることができません。

C++ Development with Visual Studio Code

If you’re looking for a fast and lightweight open-source code editor, Visual Studio Code has you covered. Come for a deep dive into the features of Visual Studio Code which provide a rich, productive environment for C++ development.