I wanted to add validation rules to textBox ,the problem is that when I do the following code I got the following error message,
A value of type 'myValidations' cannot be added to a collection or dictionary of type 'Collection`1'.
The class myValidations roles is active.
What can be the problem?
<TextBox x:Name="Name" Grid.Column="4" Margin="0,50,0,0" Grid.Row="2" Style="{StaticResource tooltipError}">
<Binding ElementName="textBlock" Path="Text">
<Binding.ValidationRules>
<viewModel:MyValidationsRules/>
</Binding.ValidationRules>
</Binding>
</TextBox>
The text boxes are inherit from the following style:
<Style TargetType="TextBox">
<Setter Property="AcceptsReturn" Value="True"/>
<Setter Property="AllowDrop" Value="True"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="Height" Value="44"/>
<Setter Property="Width" Value="199"/>
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<EventSetter Event="PreviewDragEnter"
Handler="DropText_PreviewDragEnter"/>
<EventSetter Event="PreviewDrop"
Handler="DropText_PreviewDrop"/>
<EventSetter Event="PreviewDragOver"
</Style>