Hi,
I need to show the validation error on the tooltip of the xamgrid when User is entering invalid data from new row control.
I am using IDataErrorInfo for the same, error is getting displayed to the user with a red border on the cell but no information about the error is getting displayed.
I tried a lot but my trigger is not working.
Can someone please suggest me with a sample of how to work this out.
Below is what i tried to get it displayed but it didn't worked.
<ig:TextColumn.EditorStyle> <Style TargetType="{x:Type TextBox}">
<Style.Triggers> <Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" /> </Trigger> </Style.Triggers> </Style>
</ig:TextColumn.EditorStyle>
Please help.
Thanks
Rakesh
Hello Rakesh,
Thank you for your post. I have been looking into the functionality that you are trying to achieve and I can suggest binding to the indexer property of the IDataErrorInfo, in the EditorStyle of the TextColumns. Here is how you can implement the binding:
<ig:TextColumn Key="Name">
<ig:TextColumn.EditorStyle>
<Style TargetType="TextBox">
<Setter Property="ToolTip" Value="{Binding Path=.[Name]}"/>
</Style>
</ig:TextColumn>
Also, in order to be able to notify that the indexer property is changed you can use the following approach in the view model:
public class ViewModelVase : INotifyPropertyChanged, IDataErrorInfo
{
[IndexerName("Item")]
public string this[string columnName]
get
return (!errors.ContainsKey(columnName) ? null :
String.Join(Environment.NewLine, errors[columnName]));
}
…….
I have created a sample application for you, that shows how you can implement this approach.
Please let me know if you need any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
I am just checking if you require any further assistance on the matter.
Hi Krasimir,
Thanks for your support.
I am done with this task.
Thank you for your reply. I am very glad that my approach was helped solving your issue. Please let me know if you need any further assistance on the matter.