Thursday, December 23, 2010

Adding an item to a list and scrolling it into view #wp7dev

For reasons can't explain rightly explain, it was a bit tricky to add an item to a list (in a Windows Phone 7 application - unsurprisingly) and then scroll the list so the new item was displayed.

I eventually got this working by forcing the call to scroll the new item into view on the UI thread.

Consider this in a default DataBound application:

  private void ApplicationBarIconButton_Click(object sender, EventArgs e)
  {
    App.ViewModel.Items.Add(new ItemViewModel
                                {
                                  LineOne = "new L1",
                                  LineTwo = "new L2",
                                  LineThree = "new L3"
                                });
 
    Dispatcher.BeginInvoke(() =>
      MainListBox.ScrollIntoView(MainListBox.Items.Last()));
  }


Without doing this, the list will scroll to the item which was previously the last on the list.

1 comment:

  1. We’ve furthermore integrated several hublot replica uk photographs of your prototype with the glowing blue switch Glashütte Authentic 70s Chronograph Panorama Time in which been to our own retailer earlier. The particular Glashütte Authentic 70s Chronograph Panorama Time omega replica uk characteristics additional issues compared to the brand’s some other chronographs who have appear just before that. The particular 60s Chronograph, Senator XL Chronograph, as well as the today outdated Navigator Chronograph almost all chanel replica sale highlighted variants with the Calibre 39 movements. These kinds of chronographs are typical non-date designs, featuring a bi-compax structure together with a couple of subdials. The particular Glashütte Authentic 70s Chronograph Panorama Time cartier replica sale contributes many issues which can be a primary regarding Glashütte Authentic: a huge (panorama) time, flyback, 12-hour sign up, plus a strength arrange meter. Because it will be their particular initial column tyre chronograph, the particular louis vuitton replica sale option actions will be clearly simpler as compared to their particular some other chronographs. Inside their news release for your bit, Glashütte Authentic identifies the particular column tyre device since basic rolex replica uk and also made up of much less personal elements when compared to a common column tyre chronograph.

    ReplyDelete