开发者

WP7 Listbox Automatic Scrolling Using MVVM

I have a ListBox that I've bound to a List of ordered times. When the ListBox loads I'd like to show the item that will be next at the top of the screen.

Is there a way to do this in WP7 using MVVM? I've looked around and there seems to be solutions f开发者_如何学Pythonor WPF but I can't seem to find any for WP7.


I can think of two ways of doing this:

  1. Implement an attached property that calls ScrollIntoView when the value changes (this method seems cleaner, but I'm not 100% sure it will work on WP7's Silverlight 3 runtime)
  2. Implement it as a Blend Bahavior that supports a bindable property (the ButtonCommand behavior in P&P's WP7 Guide has some trickery to achieve this on SL3) that calls ScrollIntoView when the bound value changes.

It's worth noting that ScrollIntoView only ensures the value is visible, not that it's at the top.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜