The app used to work fine, but a few weeks ago we updated hundreds of NuGet packages. We recently discovered that any reference to a WPF Behavior gives the following error:
System.Windows.Markup.XamlParseException: ''Add value to collection of type 'Microsoft.Xaml.Behaviors.BehaviorCollection' threw an exception.' Line number '78' and line position '86'.'
Inner Exception ArgumentException: Cannot add instance of type 'TextBoxInputBehavior' to a collection of type 'BehaviorCollection'. Only items of type 'T' are allowed.
I suspect this is because of a NuGet update, but I don't know which one had caused the error, or which need to be changed. I'm using the latest version for Microsoft.Xaml.Behaviors.Wpf (1.1.31).
I would appreciate advice. Thanks.
Code:
xmlns:Behaviors="clr-namespace:MyCompany.MyProject"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
<TextBox Text="...">
<i:Interaction.Behaviors>
<Behaviors:TextBoxInputBehavior InputMode="DecimalInput" JustPositiveDecimalInput="False" RangeMin="-1000000.000" RangeMax="1000000.000" />
</i:Interaction.Behaviors>
</TextBox>
//...
using Microsoft.Xaml.Behaviors;
//...
public class TextBoxInputBehavior : Behavior<TextBox>
//...