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
35
XamDataGrid performance problems whilst data bind operation
posted

Hi Infragistics Team,

I'm fighting with a WPF XamDataGrid performance and can't figure out why entire applciation is blocked (UI freeze) whilst grid data binding. As first thing let me provide you with some info:

1. Components version: 11.1
2. Following performance optimization settings were applied:

  1. Updating the FieldCollection using BeginUpdate() ... EndUpdate()
  2. ScrollingMode=DeferredWithScrollTips
  3. Suppressed events: TextChanged, ValueChanged
  4. Adjusting Cell Presenter Virtualization:  
  5. CellContainerGenerationMode, RecordContainerGenerationMode="LazyLoad" 

3. Grid usage scenario:

 3.1 Data set to be bound is really small:19 columns, ~200 rows
 3.2 Grid receives data updates each 30 seconds, whilst data update we receiving entire data set so we have to rebind entire data grid this is one of the reasons why we bound data itemd to a grid without using INotifyCollectionChanged -based data source since we can not support specific row/cell data update for now, and we have to bind entire data set each time. Each cell value is wrapped by Object - not a custom entity. So we just bound two-dimensions array to grid.DataSource.
 3.3 Depends on a metadata of a column - cells could be highlighted by a custom background color for this we are using StyleSelector set in the View:

<igDP:XamDataGrid.FieldSettings>
     <igDP:FieldSettings
           CellValuePresenterStyleSelector="{StaticResource GridCellValuePresenterStyleSelector}"

In StyleSelector.SelectStyle() we just analyzing a CellValuePresenter.Field.Tag value and then select either default empty style or custom one which allows us provide a custom background depends on metadata (see below), SelectStyle() method really simple, two if() conditions with check for null and one cast of the CellValuePresenter.Field.Tag to a custom entity just to check whether conditionalCellStyle should be returned for this cell:

<Style x:Key="conditionalCellStyle" TargetType="{x:Type igDP:CellValuePresenter}">
 <Setter Property="Background">
  <Setter.Value>
    <MultiBinding Converter="{StaticResource GridCellExpressionToBrushConverter}">
        <Binding Path="DataItem"/>
        <Binding Path="Field" RelativeSource="{RelativeSource Self}" />
    </MultiBinding>
  </Setter.Value>                       
 </Setter>
</Style>

Main point of this run time style selection - allows using GridCellExpressionToBrushConverter for cells which should be highlighted. I see that whislt data bind operation style selector SelectStyle() method triggered for each visible cell by assigning a custom style for it, so perhaps this caused slowness as well.


 3.4 Depends on underlying column data type we are setting custom cell Style for a entire column by creating it in runtime and assigning to the field.Settings.EditorStyle, assigning a specific XamMaskEditor with a specific mask value, this is done once when grid is created and FieldsLayout has been created. !!! Whilst data updates we do not touch Fields Layout and just bind data to the grid.DataSource.

 Question:

Whilst data update (19*200 cells) entire application is blocked (UI freeze), looks like UI thread is overloaded by a work whilst binding such a small data set. I'm not sure what is the main reason of such slowness, perhaps we doing some common mistakes oryou coudl advice us regarding better approach to use? 

 

Any help would be appreciated,
thanks

  • 27093
    posted

    Hello,

     

    I have been looking into your issue and even though I wasn’t sure how your styles at style selectors are configured, I have been able to run a XamDataGrid witouh any performance optimizations whatsoever, that has 24 columns a thousand records and rebinds every 3 seconds without any performance overhead. I assume the behavior you described might be caused by the style you are applying, so I was wondering if you could modify the sample I have created for you (DataGrid_update_data.zip) to reproduce your behavior.

     

    Looking forward to hearing from you.

    DataGrid_update_data.zip
  • 27093
    posted

    Hello,

    I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.