Problem summary: code-behind positioning is ignored if some tiles are collapsed unless a delay is introduced.
I have 12 tiles in 2 columns, all in restored state.
When all have their visibility set to visible I can set the position in the constructor of the hosting usercontrol and it works.
However if some of the tiles are collapsed, then the positioning is ignored (it seems) unless I introduce a delay of about 1/2 sec.
I tried putting the positioning code in the usercontrol loaded event, and even in the tileview loaded event, with no improvement.
It seems that if tiles with a position prior the ones being positioned are collapsed the problem occurs.
I noticed that if the position of the 12 tiles are defined in xaml as 0,1,2,3,4,5,6,7,8,9,10,11, that is, in order, then when tiles 2..6 are set to collapsed then the position order at run time is 0,1,2,2,2,2,2,2,3,4,5,6. So the collapsed tiles all have a position of 2, and tile 7 has a position of 2, 8-3, and so on.
When I set the position I only position visible tiles, and then with the position index starting with 0 and ending with visible_count-1, like in the 2nd set of position orders above. I do not set the positions in order of position but rather in order of occurrence, that is for example I iterate through the tile list and set the position of item 0 to 3, item 1 to 0, item 2 to 2, and so on.
I have IsItemsAnimationEnabled = False and PreservePositiojnWhenMaximized=True
I'm giving you all this info because I don't know what is relevant and what is not. Again, if I introduce a timer delay the tiles position properly.