Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF DataGrid - Validation Recommendations
    primarykey
    data
    text
    <p>We are implementing a WPF business application using MVVM. Currently we are trying to determine the best way to show validation errors for DataGrids. Currently we are trying to do so like this:</p> <p>1) A View user control contains a datagrid bound to an EntityCollection of Entity Framework objects located in the associated ViewModel</p> <p>2) The ViewModel implments the IDataErrorInfo interface. In the ViewModel there are the normal properties including a property for implementing IDataErrorInfo.Item</p> <p>3) The property which implements IDataErrorInfo.Item calls the validation from the underlying Model to determine if there are any validation issues</p> <p>This works fine for any textbox or combobox on the view - validatiosn are being processed as expected. But with the datagrid we are stumped - no matter what we have tried the validation will not happen. Currently it is defined like this:</p> <pre><code>&lt;DataGrid x:Name="dgWikiNames" ItemsSource="{Binding Wiki_Names, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnSourceUpdated=True}" AutoGenerateColumns="False"&gt; &lt;DataGrid.RowValidationRules&gt; &lt;DataErrorValidationRule ValidationStep="UpdatedValue"/&gt; &lt;/DataGrid.RowValidationRules&gt; &lt;DataGrid.Columns&gt; &lt;DataGridTextColumn Header="First Name"&gt; &lt;DataGridTextColumn.Binding&gt; &lt;Binding Path="First_Name" ValidatesOnDataErrors="True"&gt; &lt;Binding.ValidationRules&gt; &lt;DataErrorValidationRule/&gt; &lt;!--&lt;local:CellDataInfoValidationRule ValidationStep="UpdatedValue"/&gt;--&gt; &lt;/Binding.ValidationRules&gt; &lt;/Binding&gt; &lt;/DataGridTextColumn.Binding&gt; &lt;/DataGridTextColumn&gt; &lt;DataGridTextColumn Header="Is Primary" Binding="{Binding Primary_Flag}"/&gt; &lt;/DataGrid.Columns&gt; &lt;/DataGrid&gt; </code></pre> <p>If anyone has any pointers or recommendations we'd appreciate it. Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload