C# 更改列表框样式而不转到顶部

C# 更改列表框样式而不转到顶部,c#,windows-phone-7,xaml,windows-phone-8,C#,Windows Phone 7,Xaml,Windows Phone 8,我有一个绑定到列表框源的ObservableCollection。ListBox使用样式在ListBox的末尾显示一个按钮以“加载更多”内容。加载最后一个内容时,我会更改列表框的样式,使其显示“不再有帖子” 问题是,更改样式时,列表框会转到顶部(第一项)。。有什么办法防止这种情况发生吗 // iterate over items foreach (Record rec in root.data.records) { // add items to observablecollection

我有一个绑定到列表框源的ObservableCollection。ListBox使用样式在ListBox的末尾显示一个按钮以“加载更多”内容。加载最后一个内容时,我会更改列表框的样式,使其显示“不再有帖子”

问题是,更改样式时,列表框会转到顶部(第一项)。。有什么办法防止这种情况发生吗

// iterate over items
foreach (Record rec in root.data.records)
{
    // add items to observablecollection
}

// check if there are more items
if (root.data.nextPage == 0)
{
    // there are no more items => set style with "no more posts"
    Dispatcher.BeginInvoke(() => listbox.Style = (Style)App.Current.Resources["listboxend"]);
    return;
}
else
{
    // there are still more items => set style with button
    Dispatcher.BeginInvoke(() => listbox.Style = (Style)this.Resources["listboxwithbutton"]);
}

奇怪的是:一开始列表框没有样式。当我设置“listboxwithbutton”样式时,listbox不会位于顶部。。。仅当设置“listboxend”样式时。

无论何时更改样式,都可以使用
ListBox.ScrollIntoView(listBoxItem)
滚动到listBoxItem。假设你现在知道如何获得这个。祝你好运。

我不能使用此功能,因为我在“加载更多”功能中更改了样式,并看到此时添加的下一项是最后一项。因此,当我更改样式时,用户没有滚动到底部。我希望你能理解。