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
220
How to show data validation error messages on grid itself.
posted

Hi, 

we are using InfragisticsWPF4.v10.2. in our  case there is no possibility to implement IDataErrorInfo on the business class object. and our scenario is like this:

we have XamGrid, that contains one column as DropDown. this DropDwon is bound to some other DataSource that populates values on some other selection criteria on other control then XamGrid.

One of the Property of business object is binded to this Dropdown column. using MVVM pattern we change the value of this Property and there is a validation, that checks if the value is not found in DropDown then show Error. 

How i should do this?

I did same thing with ListView control of .Net Framework and it did work as expected. it showed the error icon and the tooltip as required. To achieve this behavior, I created a ValidatonRule and binded to the DropDown.

-----------------------------------------------------------------------------------------------------------------------------------------

XamDataGrid UnBound Column

-----------------------------------------------------------------------------------------------------------------------------------------

                            <igDP:UnboundField Name="SubmitMethod" Label="Submit Method" Width="50" Column="2"  Row="1"  >

                                <igDP:UnboundField.Settings>

                                    <igDP:FieldSettings    LabelWidth="0" AutoSizeScope="RecordsInView" CellValuePresenterStyle="{StaticResource SubmitMethod}" SupportDataErrorInfo="True" DataValueChangedNotificationsActive="True" />

                                </igDP:UnboundField.Settings>

-----------------------------------------------------------------------------------------------------------------------------------------

XamDataGrid UnBound Column Style

-----------------------------------------------------------------------------------------------------------------------------------------

 

<Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="SubmitMethod">

                        <Setter Property="Template">

                            <Setter.Value>

                                <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">

                                    <StackPanel Orientation="Vertical">

                                        <TextBlock Text="{Binding Path=DataItem.SelectedSubmitMethod}"/>

                                        <ComboBox Height="20" MinWidth="25" 

                                            ItemsSource="{Binding 

                                                        Converter={StaticResource MethodToValueConverter},

                                                        ConverterParameter='GetAvailableSubmitMethods',

                                                        UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"

                                            DisplayMemberPath="Key" 

                                            SelectedValuePath="Value" 

                                            IsSynchronizedWithCurrentItem="True" >

                                            <ComboBox.SelectedValue>

                                                <Binding Path="DataItem.SelectedSubmitMethod" UpdateSourceTrigger="PropertyChanged"  Mode="TwoWay" ValidatesOnDataErrors="True" ValidatesOnExceptions="True" >

                                                    <Binding.ValidationRules >

                                                        <StaticResource ResourceKey="ComboBoxSelectedItemValidationRule"/>

                                                    </Binding.ValidationRules>

                                                </Binding>

                                            </ComboBox.SelectedValue>

                                            <Validation.ErrorTemplate>

                                                <ControlTemplate >

                                                    <DockPanel>

                                                        <TextBlock Foreground="Red" FontSize="20" FontWeight="Bold">!</TextBlock>

                                                        <AdornedElementPlaceholder/>

                                                    </DockPanel>

                                                </ControlTemplate>

                                            </Validation.ErrorTemplate>

                                        </ComboBox>

                                    </StackPanel>

                                </ControlTemplate>

                            </Setter.Value>

                        </Setter>

                    </Style>

 

 

Is it Possible to do this with Infragistics?

  • 138253
    Offline posted

    Hello,

     

    Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this answer as well.

     

    Thanks again.

  • 220
    posted

    Never Mind.. it was my Custom ValidationRule.. that was reseting value. That's why the error was not shown...