Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Error while adding validation rules

$
0
0

HI ,

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><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>



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>