Add a Validation message to UWP DataGrid

Allanjb 246 Reputation points

I am developing an App that utilizes the UWP DataGrid control.
The control handles validation by turning the background red for scenarios where I have implemented INotifyDataErrorInfo, GetErrors(), HasErrors() and the ErrorsChanged event handler. This level of Validation is built into the control.
The problem with this is that the control does not display the error message returned by GetErrors().
I would like to display the error message below the Cell that has the error similar to what I can do in WPF.
I cannot find a solution anywhere for doing this.

Universal Windows Platform (UWP)
{count} votes

Accepted answer
  1. Roy Li - MSFT 32,731 Reputation points Microsoft Vendor


    Welcome to Microsoft Q&A!

    I want to show below the cell that contains the error.

    First of all, the community toolkit DataGrid is different from the DataGrid in WPF. The Input Validation in the community toolkit DataGrid will only change the background row. You could also check this behavior in the official document: Input Validation.

    For your scenario, I'd suggest you might need to custom the RowDetailsTemplate which could be used to display the error message. You could follow the document here: Display and Configure Row Details in the DataGrid Control. What you need to do is to create a DataTemplate that defines the appearance of the row details section first. Then place the DataTemplate inside the <DataGrid.RowDetailsTemplate> tags.

    The code looks like this:

             <StackPanel Margin="20,10" Padding="5" Spacing="3">  
                <TextBlock Margin="20" Text="Error messages"/>     

    You could also try to submit a feature request in the Community Toolkit GitHub Issue about this.

    Thank you.

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

0 additional answers

Sort by: Most helpful