Not sure if this is a bug or expected behavior. If it’s expected, getting some tips on what’s going on under-the-hood would be great so I can work with instead of around the issue…
I have custom cells which pull their data from the internet (e.g., downloading an image) and display them in a canvas control within the container.
For this reason, the data source will create all the cells it needs when created/refreshed and saves them in an array. The
RowCount method is just the
Count of the array and the
RowData method is just returning the cell at the given row that already exists. This way, as the user scrolls around, they aren’t re-downloading the same data every single time the cell happens to get back onto the screen.
Now to the issue…
Something within Xojo seems to be caching the rendered canvas data or something. I have some user interactions which allow them to reload the data source with new data (e.g., data from a different day). When this happens, I
RemoveAll the cells from array and
table.CreateCustomCell again for all the new cells that will contain the updated data. I then call
However, when the table refreshes, the cells rendered are a complete mess. Some are the new ones, but in the wrong order, and others are from the old table data. When I inspect the new cells, though, they are 100% correct: all the data in them is correct and fine.
What I’m forced to do is
Refresh the canvas controls within the newly created cells like so:
cells.RemoveAll for each r as Record in LoadedRecords var cell as MobileTableCellData = table.CreateCustomCell(GetTypeInfo(CustomCell)) var c as CustomCell = CustomCell(cell.Control) // Initialize members of the custom cell control here c.CustomCanvas.Refresh ' <-- doing this fixes everything! // add the cell to the data source cells.Add cell next table.ReloadDataSource table.EndRefresh
But it’s completely baffling to me why that’s the case. It should be a brand new control. It should automatically redraw the canvas as it’s brand new.
If it’s using cached render surfaces for performance, I totally get that, but it should still force a redraw automatically, I’d think.
If I try and put the
Refresh somewhere else, like in the
Opening event or
Constructor, then it doesn’t work. It only seems to work if I call it the way I’m doing it above.