Freezing a listboxitem while items are being added

Posted by siz on Stack Overflow See other posts from Stack Overflow or by siz
Published on 2010-03-11T21:42:19Z Indexed on 2010/03/11 21:44 UTC
Read the original article Hit count: 154

Filed under:
|

We have a ListBox that has a number of items. Items are inserted into the ListBox via an ObservableCollection. Some of these items can be edited right in the ListBox. However, if an item is added at an index < the edited item's index, the entire content of the ListBox moves down.

What we'd like to do is the following: if an item is in edit mode, we'd like to freeze its position on the screen. It is fine if items are added to the collection and the UI around the item changes. But the position of the item should remain constant on the screen.

The only thing I've been able to do so far is attach to the ScrollChanged event and, at most, use either BringIntoView or ScrollIntoView methods to ensure that the item is always displayed somewhere in the UI, but I am unable to lock down its position.

Has anyone done something like this and help out?

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf