Validation in 3.0 with WPF question

Validation in 3.0 with WPF question

Old forum URL: forums.lhotka.net/forums/t/3458.aspx


RockoWPB posted on Thursday, August 30, 2007

I'm working on a WPF tooltip that shows the list of errors for a control. I've added a String required and Min length rule to the controls CSLA property. Everything work fine except that I only get 1 error at a time. I've set the stopprocessing to false and the severity to 0 for both rules, but I still only get one error at a time. Any suggestions would be appreciated.

 

P.S. is it possible to access the error severity in the XAML. Would love to be able to issue warnings to the user too.

My tooltip is in a controltemplate and the XAML looks like this.

<ToolTip x:Name="ErrorToolTip" >

<ListBox ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Validation.Errors)}" >

<ListBox.ItemTemplate>

<DataTemplate>

<TextBlock  Text="{Binding Path=ErrorContent}" />

</DataTemplate>

</ListBox.ItemTemplate>

</ListBox>

</ToolTip>

RockfordLhotka replied on Saturday, September 01, 2007

Validator works like the Windows Forms ErrorProvider, and so only shows one of the errors for a property. IDataErrorInfo (the underlying .NET interface) merely returns a string with the error description, it has no concept of severity or a list of errors or anything like that. This restricts what can be done at the UI level while still conforming to the standard interface.

I debated whether to stick with IDataErrorInfo or not, but decided I would use it. The reason is that Microsoft is planning some sort of ErrorProvider equivalent for WPF and it will use IDataErrorInfo. By sticking with their interface, I make it possible to eventually abandon the CSLA .NET Validator control when Microsoft comes out with their solution.

Copyright (c) Marimer LLC