This is a migrated thread and some comments may be shown as answers.

Custom Cells in GridView and Event Handlers

1 Answer 64 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
CHRISTIAN
Top achievements
Rank 1
CHRISTIAN asked on 14 Apr 2014, 12:16 PM
Hello,

I have to fix an existing GridView where some events are created to often. This occours only when scrolling in the grid.
The "CreateCellElement" Method is getting called several times and thus the events are being created too often.

        public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)
        {
              ... some code....

              var lookup = new CustomCell(cell, dataItem, var, var2);

              cell.MouseLeftButtonDown += lookup.OnMouseLeftButtonDown;
              cell.KeyDown += lookup.OnKeyDown;
              cell.KeyUp += lookup.OnKeyUp;

            return lookup;
        }

This happens when "EnableColumnVirtualization"  and "EnableRowVirtualization" is set to true.
Well, i cant set them to false because the grid is allready too slow.

First i tried to delete the events with "-=" on "Unload" but that doesn´t work.

How can i prevent that the events getting attached?

Regards

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 17 Apr 2014, 09:56 AM
Hello,

When the virtualization of RadGridView is turned on, its elements are created when they should be brought into view and they are also reused on scrolling (i.e. the rows/cells are recreated on scrolling). Thus, it is not recommended to work with the visual elements (i.e. GridViewRow/GridViewCell) and their properties. You can take a look at the UI Virtualization help article for a reference. 

Regards,
Yoan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
CHRISTIAN
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or