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
EDIT: The same behavior can be observed in the new 2019 preview of VS. Am I going crazy?