Grid data ghosting problems when scrolling

4 posts, 0 answers
  1. Kristjan Einarsson
    Kristjan Einarsson avatar
    95 posts
    Member since:
    Jan 2010

    Posted 25 Mar 2013 Link to this post

    Hi,
    When I am using a custom column and am scrolling in the treelistview the data seems to move around.
    In the screenshot the data that is zero should not be zero. but there are columns that are zero. If I scroll around allot all columns will end up having the same number.

    I am using version: 2013.1.311.40

    here is my custom column code

    public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)
            {
                Grid cellGrid = cell.Content as Grid;
                 
                TextBlock primaryText = new TextBlock(){ TextAlignment = System.Windows.TextAlignment.Right };
                TextBlock compareText = new TextBlock() { TextAlignment = System.Windows.TextAlignment.Right, Foreground = new SolidColorBrush(Color.FromRgb(100, 100, 100))};
     
                if (string.IsNullOrEmpty(this.DataMemberBinding.StringFormat))
                {
                    this.ComparedPlanBinding.StringFormat = this.DataFormatString;
                    this.DataMemberBinding.StringFormat   = this.DataFormatString;
                }
                 
                primaryText.SetBinding(TextBlock.TextProperty, this.DataMemberBinding);
                compareText.SetBinding(TextBlock.TextProperty, ComparedPlanBinding);
     
                if (cellGrid == null)
                {
                    cellGrid = new Grid();
                    cellGrid.ColumnDefinitions.Add(new ColumnDefinition());
                    cellGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(20)});
                    cellGrid.ColumnDefinitions.Add(new ColumnDefinition());
                    cellGrid.RowDefinitions.Add(new RowDefinition());
     
                    cellGrid.Children.Add(primaryText);
                    Grid.SetColumn(primaryText, 0);
                    Grid.SetRow(primaryText, 0);
     
                    cellGrid.Children.Add(compareText);
                    Grid.SetColumn(compareText, 2);
                    Grid.SetRow(compareText, 0);
                }
                return cellGrid;
            }

    This only a problem when I scroll. Can you please advice.

    Best regards
    Kristján
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 26 Mar 2013 Link to this post

    Hello,

    Since the virtualization of RadGridView is turned on by default, it is not recommended to work with the visual elements and their properties. You can take a look at this article for a reference on UI Virtualization. 

    In your code you work with the Cell.Content. Would it be possible for you to avoid using it and rely on the DataMemberBinding only?
     

    Regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Kristjan Einarsson
    Kristjan Einarsson avatar
    95 posts
    Member since:
    Jan 2010

    Posted 26 Mar 2013 Link to this post

    Hi,
    When I disabled the visualization it works.

    "In your code you work with the Cell.Content. Would it be possible for you to avoid using it and rely on the DataMemberBinding only?"
    Not sure, but I need to have custom cells. Can I accomplish that without doing it the way I'm currently doing ?
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 27 Mar 2013 Link to this post

    Hello,

    You can check this help article on how to set a custom content for the cell. 

    Kind regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top