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
320
Restyle invalid cells and restyle error tooltip and its placement using MVVM
posted

I'm using Infragistics XamDataGrid version 15.1

How do I restyle the invalid cells with DarkRed background and lighter red border.

I also would like to restyle the error tooltip with Red background and white foreground (white letters), I the placement of the tooltip to be to the right of the cell.

See the sample mockup below.

Thanks

" alt="Custom Invalid Cell and restyle error tooltip" width="750" height="200" />

Parents
No Data
Reply
  • 6365
    Offline posted

    Hello Marlon,

    Thank you for the description of the invalid value styling behavior you are looking for.

    In order to restyle the cells with invalid values, along with their tooltips when using MVVM, I can suggest you implement the IDataErrorInfo interface for the underlying DataItem class (implementing INotifyPropertyChanged is preferable as well) and style the data errors respectively.

    XAML:

    <!--============ Style for error icon ============-->

    <Style TargetType="{x:Type Control}" x:Key="{x:Static igDP:DataPresenterBase.DataErrorIconStyleKey}">
        ...
    </Style>

    <!--============ Style for error content ============-->

    <DataTemplate x:Key="{x:Static igDP:DataPresenterBase.DataErrorContentTemplateKey}">
        ...
    </DataTemplate>

    <!-- ============= Enable support for DataErrorInfo ============= -->

    <igDP:XamDataGrid.FieldLayoutSettings>
        <igDP:FieldLayoutSettings SupportDataErrorInfo="CellsOnly" DataErrorDisplayMode="ErrorIconAndHighlight" />
    </igDP:XamDataGrid.FieldLayoutSettings>

    ViewModel.OrderEntry (DateItem class):

    public class OrderEntry : INotifyPropertyChanged, IDataErrorInfo, IEditableObject
    {
        ...
    }

    For more detailed information on using the data error info functionality of the XamDataGrid, I can suggest you take a look at the "xamDataGrid > Display > IDataErrorInfo Support" sample from our WPF Samples Browser and the following topics:

    Validate Data as Your End Users Edit a Cell
    Enable Data Error Information Support
    Styling Data Errors

    I have attached a sample application that demonstrates the approach from above.

    If you have any questions, please let me know.

    XamDataGrid_sample_IDataErrorInfo.zip
Children