Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1915
Setting XamComboEditor's Validation.ErrorTemplate has no effect
posted

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>

Parents
No Data
Reply
  • 17475
    Offline posted

    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.

Children