In my MVVM project I use IDataErrorInfo to propagate exception text to the UI using standard WPF Validation mechanism. With XamComboEditor 2013.1 setting Validation.ErrorTemplate to a customized control template has no effect. In this case, on validation error Control Template should show red border around the control and exception message in white bold font on a red background should show underneath the XamComboEditor but that does not work - instead I see a red border and exception message in default font to the side of the control. That same ControlTemplate works just fine with standard WPF ComboBox - I checked.
From reading this forum I've seen a couple of suggestions on re-templating XamComboEditor but I have not been able to redefine it to match my ControlTemplate (below). One of these discussions is located here: http://es.infragistics.com/community/forums/t/48422.aspx
If re-templating the XamComboEditor is really the correct solution for this problem, I would appreciate a sample utilizing my Validation.ErrorTemplate snippet below. Thanks!
XAML definition of the control:
<ig:XamComboEditor ItemsSource="{Binding MyList}" SelectedItem="{Binding SelectedItem, Mode=TwoWay, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource ComboBoxErrorTemplate}" EmptyText="Choose item..." DisplayMemberPath="Name" IsEditable="True" AutoComplete="True" AllowDrop="False"/>
and my Validation control template:
<ControlTemplate x:Key="ComboBoxErrorTemplate"> <StackPanel Orientation="Vertical"> <AdornedElementPlaceholder x:Name="ErrorAdorner"> <Border BorderBrush="Blue" BorderThickness="1" /> </AdornedElementPlaceholder> <TextBlock Text="{Binding AdornedElement.(Validation.Errors).[0].ErrorContent, ElementName=ErrorAdorner}" Background="Blue" Foreground="White" FontWeight="Bold" VerticalAlignment="Center"/> </StackPanel> </ControlTemplate>
Hi,
I am checking if this is still an issue for you.
If you require any further assistance, please do not hesitate to ask.
Hello,
Attached is a sample project that illustrates how the validation template could be modified for the XamComboEditor. I noticed that there is one more dot than needed in the binding path for the validation error (just before the “[0]”) which might be the cause the text is not correctly displayed on your side. Please have a look at the sample project and let me know if you need additional assistance.
Infragistics support, can someone please chime in?
Maria, as I have mentioned I played around with this but was NOT able to make my template appear. I would appreciate a sample. Thanks.
Hello Andre and thank you for posting!
XamComboEditor has a ValidationErrorElement that is defined in its default template and it is used to display the red border when there is an error. I would suggest you to modify this default element in order to apply a custom error template for the editor. The style could be found in the generic.xaml file which is located in the Infragistics folder (C:\Program Files (x86)\Infragistics\2014.1\WPF\DefaultStyles\XamComboEditor).Please feel free to let me know if you need additional assistance on this.