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
1735
XamPropertyGrid validation
posted

I am struggling to get validation in the XamPropertyGrid to work as expected, and have a couple of questions:

1. Out of the box, the XamPropertyGrid looks to be handling exceptions thrown in my object's properties by displaying a dialog box when I press Enter in the corresponding editor. Is there any built-in way to customize this experience to use custom validation error templates directly in the editors?

2. To get a custom validation error experience I have tried writing my custom editors, as e.g. the simple editor below for strings:

<ig:PropertyGridEditorDefinition TargetType="system:String">
 
<ig:PropertyGridEditorDefinition.EditTemplate>
   
<DataTemplate>
      <TextBox Background="LightBlue">
       
<TextBox.Text>
         
<Binding Path="Value"
                   Mode="TwoWay"
                   UpdateSourceTrigger="PropertyChanged">
            <Binding.ValidationRules>
              <validationRules:StringNotEmptyValidationRule />
              <DataErrorValidationRule />
              <ExceptionValidationRule />
            </Binding.ValidationRules>
          </Binding>
       
</TextBox.Text>
      </TextBox>
    </DataTemplate>
  </ig:PropertyGridEditorDefinition.EditTemplate>
</ig:PropertyGridEditorDefinition>

The problem with the above editor is that any custom validation error template is not used when my properties are e.g. throwing exceptions (using the ExceptionValidationRule). The built in DataErrorValidationRule has the same issue.

However, if I add my own validation rule everything works as expected. In the above code I have a custom validation rule that checks for empty strings. Triggering this rule show the validation error template correctly, as shown in the attached image. Throwing an exception in my property setter show no error indication at all.

How can I get proper validation in my custom editor?

Regards,
Leif

  • 1990
    posted

     Hello Leif, 

    Thank you for your post. 

    Regaring the issue with ExceptionValidationRule I have logged this behavior with our developers in our tracking system, with an issue ID of 208109. I have also created a support ticket on your behalf with number CAS-165503-F0P8G5 in order to link the development issue to it so that you are automatically updated when a Service Release containing your fix is available for download.

    Regarding your question about the custom validation error templates since we usually handle a single issue per support ticket, in order to provide you with better and more accurate support, I have created a separate support ticket for you regarding the question that you are having. The number of the support ticket is CAS-165606-L1L7M9 I will keep this case open for another three days while I wait for your response. If at that time you haven't responded, I will close this case.  Please note that closed cases may be reopened within thirty days of closure.

    Sincerely,

    Horen

    Software Developer

    Infragistics

    www.infragistics.com/support