I have a list of objects with X
,Y
properties. I want to put the collection into ItemsControl
and position each item according to its x and y.
I don't know the maximum of X or Y.
I tried to use Canvas
as ItemsControl.ItemsPanel, but Canvas doesn't change its size based on its children. Thus ScrollViewer cannot scroll ItemsControl.
I checked How to Visible ScrollBar In Items Panel With Canvas as ItemsPaneltemplate. The first solution is to use Grid and set Margin. However, Thickness.X and Thickness.Y are not dependency properties and not bindable. The second solution is OK but involves code-behind. The last solution should also work but writing a new class is laborious.
How to position items in ItemsControl and enable scroll? What solution do you prefer?