Tutorial :Silverlight DataGrid Redraw Issue



Question:

I have a Silverlight DataGrid that contains a single template column which displays a user control. The user control has a progress bar to represent processing and when the processing is complete an animation hides the progress bar and shows a finished label.

There are two instances in which the datagrid seems not to redraw itself:

First, when a user does a lot of scrolling then the datagrid will start by redrawing the animation when the usercontrol comes into view and will finally reach a point where it doesn't redraw anything.

Second, there is a click event in the usercontrol that displays a popup. When the popup is closed then again the usercontrol fails to redraw itself properly.

Any ideas as to why this behavior occurs and ways around it?


Solution:1

The previous answer is correct. I have found that sometimes you have to properly handle the Loading_Row and Unloading_Row events if you want any of your controls to behave properly. In my cases having the controls properties actually bound to an object to work best. If you try to rely on animations and visibility and the like you will see strange behavior but if you bind the progressbar to an object that is maintaining the progress for each item behind the scenes then every time that row is shown it will rebind and redraw.


Solution:2

You have to understand that a DataGrid does not have one instance of your control for every row in the grid. The data source could have millions of rows, while the grid doesn't need more instances of your control than will fit on the screen. This means that when you scroll, for instance, it doesn't reveal instances of your control previously invisible; it just assigns the currently-visible controls whatever values are needed to make the correct display for the current scroll position.

I don't know if there is a workaround.


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