Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Any ideas why 'scroll into view' works for a while but then the list goes back to the top?

$
0
0

I have a ListBox that is bound to a collection and its SelectedIndex bound to a property within a model. This works as one would expect, the ListBox is properly populated and the ListBoxItem that corresponds to the property in the model properly results in the selection of an item in the list. So far, so good. There was a problem (isn't there always?) that I fixed by hooking the SelectionChanged and SizeChanged events. The ListBox is during these times commanded to scroll the selected item into view and this also works just fine. The problem is that quite often the ListBox's scrolled position reverts to 0 again, hiding the selected item again. The selected index is not being modified. It remains unchanged. I've tried hooking all of the events I can in the ListBox in an attempt to determine which event is triggering the scrolling of the ListBox but none of them are getting hit.

A complicating factor is that there are a number of BackgroundWorker threads that come and go, depending upon which particular state the application is currently operating in. The loss of visible ListBoxItem is in some fashion associated with these worker threads but how is unclear. The loss of visible selected item happens often and is not limited to a single operation or thread. The threads quite often update a UI element so there are a fair number of places where the background worker makes a state transition to foreground so that a property that is bound to a UI element can be safely updated.

So, after all of that, any ideas on how I can track down who the offending event may be? What would cause the ListBox to suddenly scroll back up so that the index 0 item is at the top of it?


Richard Lewis Haggard


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>