LongListSelector and DataTemplateSelector

前端 未结 3 1143
无人共我
无人共我 2021-02-15 14:53

I\'m using the LongListSelector to realize List or Grid display for my items. For this, I created a DataTemplateSelector and I change the LayoutMode property at runtime. This is

3条回答
  •  鱼传尺愫
    2021-02-15 15:09

    I haven't got the solution but maybe a clue for someone who will solve the problem.
    I think the problem is with LongListSelector.UpdateLayout() method - when it's fired for the first time there are no items to which LLS was bound - OnChangeMethod is called that many times as the Itemsource.Count. But when we leave the page and go back - LLS is Updated and method is called ommiting the middle element.
    It means it works for even number of items - OnChangeMethod is called correct number of times, But for odd number of items - it's called numer of items - 1.
    The second thing is why it's called at all - when there are no changes.

    I also add a code to work on which (very simple).

提交回复
热议问题