Scrolling randomly changes values in textblocks

Hey, 
Problem:
I have a SfDataGrid:

 <sf:SfDataGrid
                        x:Name="ResultJobsDataGrid"
                        Grid.Row="1"
                        local:SfDataGridBehaviors.ColumnsMinimumWidth="3"
                        BorderBrush="{DynamicResource Brush.Stroke.Enabled.1}"
                        BorderThickness="0,1,0,1"
                        EnableDataVirtualization="False"
                        IsEnabled="{Binding IsBusy, Converter={x:Static controls:ValueConverters.InvertBool}}"
                        ItemsSource="{Binding Jobs}"
                        SelectedItem="{Binding SelectedJob}"
                        Style="{StaticResource Style.SFDataGrid.BrowseResults}">
                        <i:Interaction.Behaviors>
                            <local:SfDataGridBehaviors />
                        </i:Interaction.Behaviors>
                    </sf:SfDataGrid>

Displaying items bound by a datatemplate

<DataTemplate x:Key="DisplayNameCellTemplate" DataType="{x:Type local:ArchiveItemViewModel}">
    <Grid>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="*" />
      </Grid.ColumnDefinitions>
      <Image
        Width="50"
        Margin="32,0,0,0"
        Source="{Binding Thumbnail}"
        Stretch="Uniform" />
      <TextBlock
        Grid.Column="1"
        Margin="8,0,0,0"
        VerticalAlignment="Center"
        controls:FontSettings.Key="Body1"
        Text="{Binding DisplayName}"
        TextTrimming="CharacterEllipsis"
        TextWrapping="WrapWithOverflow" />
    </Grid>
  </DataTemplate>
  <DataTemplate x:Key="Document.DescriptionCellTemplate" DataType="{x:Type local:ArchiveItemViewModel}">
    <TextBlock
      Margin="8,0,0,0"
      HorizontalAlignment="Left"
      VerticalAlignment="Center"
      Text="{Binding DocumentDescription}"
      TextTrimming="CharacterEllipsis"
      TextWrapping="Wrap" />
  </DataTemplate>

This works without problems:



After applying some highlighting.
Code from Syncfusion given a few years ealier where we had an incident 
(but generally it works and the error also occurs if you just color the text/replace it with "test" strings)

e.g. just goes through the visual tree and gets all textblocks and colors them red and replaces the text

After highlighting (the rowindex and columnindex just to show the later error) it is also fine and gives the correct result:


BUT after scrolling up/down the content of the textblock changes "randomly":



We have already tried the solution mentioned in:
(overridding GridCellTextBoxRenderer or in our case GridCellTextBRenderer but to no avail)
Also changed the virtualization of the grid to false.

For completeness the visual tree:


Do you have any ideas/solutions for this behavior?





5 Replies

SS Susmitha Sundar Syncfusion Team June 17, 2020 11:21 AM UTC

Hi Johannes, 
 
Thank you for using Syncfusion controls. 
 
We need some information about your reported case “Scrolling randomly changes values in textblocks”. Can you please provide below information? 
1.       Column generation code. 
2.       Syncfusion updated version 
3.       Video reference 
It will be helpful for us to check on it and provide you the solution at the earliest.   
 
Regards, 
Susmitha S 



JJ Johannes Jilg June 18, 2020 08:52 AM UTC

Version Information:
Platform:
WPF
Control:
SfDataGrid
Product Version:
15.4.0.20
.NET Vesrion:
4.6
Visual Studio:
Visual Studio 2019
Language:
C#
Operating System:
Windows 10 64-bit

Video is attached in the zip 
-> rundown
entering our browser -> normal result list is displayed
-> searching for a specific term which returns a list of files matching 
-> where possible the text is highlighted
-> scrolling breaks the items/cells


Column Code is coming up shortly 

Attachment: Scrolling_Video_e5fcefbb.zip


JJ Johannes Jilg June 18, 2020 11:07 AM UTC

With respect to column generation code:
When the viewmodel is created the persisted information about the column (which ones are there/visible is read from xml storage)
then

/// <summary>
/// Maps a .NET type to a function which creates and configures a <see cref="GridColumn"/> for <see cref="SfDataGrid"/>.
/// </summary>
private static readonly IDictionary<Type, Func<GridColumn>> ColumnTypeMap = new Dictionary<Type, Func<GridColumn>>
{
{ typeof(bool), () => new GridCheckBoxColumn() },
{ typeof(TimeSpan), () => new GridTimeSpanColumn() },
{ typeof(DateTime), CreateDateTimeColumn },
{ typeof(byte), CreateIntegerColumn },
{ typeof(sbyte), CreateIntegerColumn },
{ typeof(short), CreateIntegerColumn },
{ typeof(ushort), CreateIntegerColumn },
{ typeof(int), CreateIntegerColumn },
{ typeof(uint), CreateIntegerColumn },
{ typeof(long), CreateIntegerColumn },
{ typeof(ulong), CreateIntegerColumn },
};
/// <summary>
/// Initialize data grid columns.
/// </summary>
public static void InitColumns(FrameworkElement control, SfDataGrid dataGrid, IEnumerable<JobDocumentUIMapping> mappings)
{
var isDocumentsGrid = (dataGrid == BrowseResultsContentManager.resultDocumentsDataGrid || BrowseResultsContentManager.resultDocumentsDataGrid == null);

foreach (JobDocumentUIMapping mapping in mappings.OrderBy(c => c.ColumnPosition))
{
var column = BrowseResultsContentManager.FindGridColumn(dataGrid, mapping.PropertyPath);
if (column == null)
{
column = GridColumnFactory.CreateGridColumn(control, isDocumentsGrid, mapping);
dataGrid.Columns.Add(column);
}

column.IsHidden = !mapping.IsVisible;
column.Width = mapping.ColumnWidth;
}
}

with respect to create:
/// <summary>
/// Create a <see cref="GridColumn"/> for <see cref="SfDataGrid"/>.
/// </summary>
public static GridColumn CreateGridColumn(FrameworkElement control, bool isResultDocumentsDataGrid, JobDocumentUIMapping mapping)
{
GridColumn column;
switch (mapping.PropertyPath)
{
// DisplayName can have a special DataTemplate named "DisplayNameCellTemplate" which contains an image and editable Text.
case "DisplayName":
column = CreateSpecialColumn(control, isResultDocumentsDataGrid, mapping);
break;
default:
column = CreateIndexedPropertyColumn(control, mapping);
break;
}

column.HeaderText = mapping.PropertyDisplayName;
column.UseBindingValue = true;
return column;
}

if you need more information let me know


VS Vijayarasan Sivanandham Syncfusion Team June 22, 2020 03:51 AM UTC

Hi Johannes Jilg,

Thanks for the update.

We are currently working on “Scrolling randomly changes values in textblocks” and we need two more business days to validate this. We will update you with further details on June 23, 2020.

We appreciate your patience until then. 
 
Regards, 
Vijayarasan S




SS Susmitha Sundar Syncfusion Team June 25, 2020 02:48 AM UTC

Hi Johannes Jilg,, 
  
We have created a new incident under your Direct trac account. We suggest you follow up with the incident for further updates. Please log in using the below link.  
  
  
Regards, 
Susmitha S 


Loader.
Up arrow icon