Closed octav84 closed 8 years ago
I wonder could this be a rounding behavior difference? Unless you are working in exactly integer screen pixel units (which isn't likely to be the case if you're running on a non-96-dpi display) XAML will do all kinds of smarts to snap UI elements to screen pixel locations.
Rather than trying to duplicate the exact layout calculations that XAML is doing for your Win2D rendering, I think a more robust approach would be to query XAML for the position of each element.
This seems like a good way to do that: http://stackoverflow.com/questions/12161584/absolute-coordinates-of-uielement-in-winrt
You mean that I need to draw every cell using the X coordinates that the XAML ListView items have ? Isn't there a better way to do this ?
Found the solution - in the OnRegionsInvalidated event handler, I got the actual width I needed to set by dividing the headers actual width to it's number of items. Strangely, the XAML ListView had drawn 150.3999... pixels wide elements instead of 150 pixel ones.
Actually, not even this was enough. Finally I took your advice and got the exact coordinates of the items I needed to align to and it worked perfectly. Thank you very much.
Hi. I have a CanvasVirtualControl rendering a table made of cells 150 units in length and 40 units in height. I need to align this table with a horizontal rendering list which also consists of elements of 150 X 40 units.
Problem is that the cells rendered with Win2D are slightly smaller in length. When scrolling horizontally all 256 columns, this problem becomes obvious. At the end of the scroll, they are clearly out of sync, the XAML horizontal list is longer by a full 2/3 cell width than the grid generated with Win2D. The XAML horizontal list acts as a header for the Win2D grid, so the length should be exactly the same.
This is the XAML:
This is the Win2D Rendering:
This is the constants class:
This is the ViewModel for the XAML page containing the CanvasMatrix:
}