WPF : The toggle button in my GridViewToggleRowDetailsColumn get visible when scrolling horizontally

239 views Asked by At

I have a radgridview with a GridViewToggleRowDetailsColumn and I can set the visibility of the GridViewToggleButton the way I want through the RowLoaded event for each row. It was working fine until I need to scroll horizontally. When the GridViewToggleRowDetailsColumn get out of the screen and I scroll back to it, the GridViewToggleButton are now all visible.

I tried to find any event triggered by this without success. Even the IsVisibleChanged event attached to the GridViewToggleButton seems to be triggered only on the visible one.

Does anyone faced the same issue or have any idea of what could produce this behavior ?

Edit: Found the answer. It was a virtualization issue. Adding EnableColumnVirtualization="False" in the gridview properties solved it.

2

There are 2 answers

0
ClearlyClueless On

https://docs.telerik.com/devtools/wpf/controls/radgridview/features/ui-virtualization

After a few minutes of research, it appears that telerik WPF GridView uses virtualization to improve performace. This means that the state of what is in the screen is retained and as things leave your viewing area they are destroyed. This frees up memory space significantly, however can have some side effects as you are experiencing.

You can set EnableColumnVirtualization=false however Telerik has provided a help article that will likely answer your question more directly while not sacrificing the performance provided by the virtualizations. A link is below and following through the steps, it looks fairly straightforward.

https://docs.telerik.com/devtools/wpf/controls/radgridview/style-selectors/cell-style-selector

0
zaphod-ii On

The recommended approach for customizing this behavior, and not turning off the virtualization, is to use a custom column. Try inheriting from GridViewToggleRowDetailsColumn and override CreateCellElement. It is the callback for creating the visual element in the cell, which is called, more or less, at the same time as RowLoaded. Then return null for those rows that you don't want to have a button for.