locked
How to add an Item into a ListView and ScrollIntoView the newly added item?

    Question

  • void Item::addEmptyItem( Windows::UI::Xaml::Controls::ListView^ itemListView ) { Item ^ a = ref new Item(); a->Title= "Title"; a->Subtitle= "subtitle"; a->Description= "description"; a->Value= 0; itemListView->Items->Append( a ); //itemListView->MakeVisible itemListView->SelectedIndex= itemListView->Items->Size-1; itemListView->ScrollIntoView( itemListView->Items->GetAt( itemListView->SelectedIndex ) ); }

    I tried this, but the new item did not become visible.

    Sunday, October 14, 2012 11:43 PM

All replies

  • Hi,

    I cannot reproduce this issue with string item.
    Would you please provide us a whole codes about this?

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Monday, October 15, 2012 6:35 AM
  • The above method addEmptyItem works until there are more Items than fit on the screen vertically.  Once the newly added Item will be added such that it won't be visible, then the ScrollIntoView does not correct the situation.  So just adding a few strings Items won't show the problem with adding an Item that needs to be scrolled from off screen back onto the screen. 

    I put the whole source code as a file attachment to http://connect.microsoft.com/VisualStudio/Feedback/details/767426  See Details.

    I also found that ScrollIntoView does work after about 6 times of clicking the Add button.

    Monday, October 15, 2012 1:52 PM