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
975
XamGrid Validation ErrorTemplate
posted

Hi

I have a TextColumn bind to a view model that implement INotifyDataErrorInfo.

When there's an error for a specific cell, the error is showed as attach image.

Here's the relevant xaml

<ig:XamGrid 
                                Name="ItemGrid"
                                AutoGenerateColumns="False"
                                ItemsSource="{Binding Items, UpdateSourceTrigger=PropertyChanged}"
                                Padding="0" 
                                RowHeight="21"
                                Focusable="False">
                                <ig:XamGrid.RowSelectorSettings>
                                    <ig:RowSelectorSettings Visibility="Visible"/>
                                </ig:XamGrid.RowSelectorSettings>
                                <ig:XamGrid.ClipboardSettings>
                                    <ig:ClipboardSettings AllowCopy="True" AllowPaste="True" CopyType="SelectedCells" CopyOptions="ExcludeHeaders"/>
                                </ig:XamGrid.ClipboardSettings>
                                <ig:XamGrid.CellStyle>
                                    <Style BasedOn="{StaticResource {x:Type ig:CellControl}}" TargetType="ig:CellControl">
                                        <Setter Property="Padding" Value="4,0"/>
                                    </Style>
                                </ig:XamGrid.CellStyle>
                                <ig:XamGrid.SelectionSettings>
                                    <ig:SelectionSettings RowSelection="Multiple" CellSelection="Multiple" ColumnSelection="Multiple"/>
                                </ig:XamGrid.SelectionSettings>
                                <ig:XamGrid.EditingSettings>
                                    <ig:EditingSettings AllowEditing="Cell"/>
                                </ig:XamGrid.EditingSettings>
                                <ig:XamGrid.Columns>
<ig:TextColumn Key="Constraint" HeaderText="Constraint" EditorVerticalContentAlignment="Stretch"/>

How can I make the red square fill the cell and how can I show the tooltip with the error message as followed http://help.infragistics.com/Help/Doc/WPF/2012.2/CLR4.0/html/xamGrid_Validating_Data.html

Thanks

Dominik

  • 30945
    Verified Answer
    Offline posted

    Hello Dominik,

     

    Thank you for our post. I have been looking into the questions that you are having and the ContentPresenter that holds the content of the cell, has VerticalContentAlignment and HorizontalContentAlignment set to Center and Left by default. If you wish to stretch the content, you can re-template the CellControl and set VerticalContentAlignment and HorizontalContentAlignment of the ContentPresenter in the template to Stretch.

     

    Regarding the tooltips, you can create a style for the TextBox that has its ToolTip bound to the error of the IDataErrorInfo and set this style as EditorStyle, for the TextColumn. I have created a sample application for you, that shows how you can implement both approaches.

     

    Please let me know if you need any further assistance on the matter.

     

    Sincerely,

    Krasimir, MCPD

    Developer Support Supervisor - XAML

    Infragistics

    www.infragistics.com/support

     

    IDataErrorInfo_ErrorTooltip.zip