I want to validate my RadGridView manually by pressing a button, but I cant' get this to work. If I set the validator to ValidatesOnTargetUpdated="True" the validation works, but I want to trigger this validaton manually. Here is the XAML code of my DataColumn:
I' ve managed to get the validator in codebehind and check every item in the datagrid, but I also have to set the bindings as invalid for the cells to display the error. I found the command System.Windows.Controls.Validation.MarkInvalid() for this, but for this command to work I need to get the binding expression of every cell. How can I get these binding expressions?
<
telerik:GridViewDataColumn
Header
=
"Error"
>
<
telerik:GridViewDataColumn.CellTemplate
>
<
DataTemplate
>
<
telerik:GridViewCell
>
<
telerik:GridViewCell.DataContext
>
<
Binding
NotifyOnValidationError
=
"True"
>
<
Binding.ValidationRules
>
<
validators:MyValidator
/>
</
Binding.ValidationRules
>
</
Binding
>
</
telerik:GridViewCell.DataContext
>
<
telerik:GridViewCell.Style
>
<
Style
TargetType
=
"{x:Type telerik:GridViewCell}"
>
<
Style.Triggers
>
<
Trigger
Property
=
"Validation.HasError"
Value
=
"true"
>
<
Setter
Property
=
"ToolTip"
Value="{Binding RelativeSource={x:Static RelativeSource.Self},
Path=(Validation.Errors)[0].ErrorContent}"/>
</
Trigger
>
</
Style.Triggers
>
</
Style
>
</
telerik:GridViewCell.Style
>
<
telerik:GridViewCell.Content
>
<
TextBlock
Text
=
"!!!"
/>
</
telerik:GridViewCell.Content
>
</
telerik:GridViewCell
>
</
DataTemplate
>
</
telerik:GridViewDataColumn.CellTemplate
>
</
telerik:GridViewDataColumn
>
I' ve managed to get the validator in codebehind and check every item in the datagrid, but I also have to set the bindings as invalid for the cells to display the error. I found the command System.Windows.Controls.Validation.MarkInvalid() for this, but for this command to work I need to get the binding expression of every cell. How can I get these binding expressions?