Björn P
Björn P

Reputation: 3

XAML PasswordBox throwing InvalidCastException during initialisation

I am working on a Windows Forms application in C# with XAML.

When a class is loaded that contains a PasswordBox, the application always crashes with a System.Windows.Markup.XamlParseException at the last Parameter of the PasswordBox with an inner Exception: InvalidCastException: Unable to cast object of type 'System.Windows.Media.Color' to type 'System.Windows.Style'. This always occurs, even if I am using the simplest of PasswordBoxes

<PasswordBox x:Name"passwordBox" Height="30" Width="300"/>

The XamlParseException would, in this example, point to the Width attribute.

Anybody know where this error could be coming from or at least how to better debug it?

Upvotes: 0

Views: 46

Answers (1)

Jonathan Perennes
Jonathan Perennes

Reputation: 133

Your error is somehow related to the passwordbox style, look in your application/window/usercontrol ressources, you may have a custom style that redifine the style of the passwordbox with a xaml error somewhere :)

Upvotes: 1

Related Questions