Validation Silverlight DataGrid shows error validating all objects | properties

I have an ObservableCollection <T>where T: INotifyDataErrorInfo.

The objects in this collection have validation errors, then I bind this collection to Silverlight 4 DataGrid, is there a way to show this validation error in the DataGrid? (show a red cell for invalid properties for each object). By default, a DataGrid shows a validation error only when I start editing a row and only for the active row.

+2
source share
1 answer

I failed with the control TextBlock, so I used the disabled. TextBox You can change the template TextBox, I want to remove the border and set its background to be really transparent.

multi row validatione

<sdk:DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Items}" IsReadOnly="False" SelectionMode="Single">
    <sdk:DataGrid.Columns>
        <sdk:DataGridTextColumn Header="Title" Binding="{Binding Title}"/>
        <sdk:DataGridTemplateColumn Header="Link" Width="100">
            <sdk:DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <TextBox Text="{Binding Link, Mode=TwoWay}" Margin="2" 
                             IsEnabled="False" BorderThickness="0" Background="Transparent"/>
                </DataTemplate>
            </sdk:DataGridTemplateColumn.CellTemplate>
            <sdk:DataGridTemplateColumn.CellEditingTemplate>
                <DataTemplate>
                    <TextBox Text="{Binding Link, Mode=TwoWay}" Margin="2"/>
                </DataTemplate>
            </sdk:DataGridTemplateColumn.CellEditingTemplate>
        </sdk:DataGridTemplateColumn>
    </sdk:DataGrid.Columns>
</sdk:DataGrid>
+2
source

Source: https://habr.com/ru/post/1764667/


All Articles