スクロールでオートロードするListBox (簡易版)
リストの最後まで読むと自動的にさらに先を読み込んでくれるリストボックスが最近の流行りだと思うんですが、Silverlightで単純にやろうとすると、ScrollViewerやお手軽なイベント、プロパティがぱっと手の届くところにありません。なので、コードビハインド側でできるだけ単純に実装した時、というサンプルです。
コントロール等はPivotテンプレートにそのまま差し込んだ状態です。
public MainPage()
{
InitializeComponent();FirstListBox.ManipulationCompleted += new EventHandler<ManipulationCompletedEventArgs>(FirstListBox_ManipulationCompleted);
}void FirstListBox_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
{
ScrollViewer scrollViewer = FindChildOfType<ScrollViewer>(FirstListBox);
if (scrollViewer != null && scrollViewer.VerticalOffset >= (scrollViewer.ScrollableHeight))
App.ViewModel.LoadData();
}
LoadData()を呼ぶ度にViewModelに増分をロードしてくるコードが仕込んであるイメージで。
タイミングやロードの仕方はいろいろあると思うので工夫してみてください。