Tutorial :DataGrid.LoadingRow event firing three times



Question:

I have a HyperLinkButton in every row of a datagrid in my silverlight app. I need to fire an event so I am adding a handler to the click event of the HyperLinkButton in the DataGrid.LoadingRow event. The problem is the event is firing three times (more accurately, the handler is being added three times. I tried removing the handler before adding it but that has no effect. Any ideas?


Solution:1

I just set the .Tag on the Hyperlink button when I add the event handler and use that as a flag that the handler has been added.


Solution:2

To add to this issue, the problem occurs probably because the LoadingRow event may actually fire several times. The Datagrid will only instantiate the row when it is needed and will recycle it when it goes out of view. Like when you start scrolling the grid.

See the remarks sections for details: DataGrid.LoadingRow event on msdn


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »