How VerticalOffset changes when Scrollable height changes while having list inside a list

Posted by Prakash on Stack Overflow See other posts from Stack Overflow or by Prakash
Published on 2012-04-04T11:15:21Z Indexed on 2012/04/04 11:28 UTC
Read the original article Hit count: 272

I am making a WP7 app which has a Listbox of UserControls. Each UserControl has an ItemsControl and Button(for getting more results). On click of the button the ItemsControl items will be increased by 5 or 10.

Now on clicking on the GetMore button of any of the usercontrols except the first or last, there will be an increase in Scrollable height(Total height of the listbox) of the ListBox but the VerticalOffset(position of scrollbar from top) of the ListBox remains same. Now the problem I am facing is that the Vertical Offset is not absolute but relative to Scrollable Height. So the content being viewed till then will be changed basing on the new value of ScollableHeight.

I want to know the relation between them, so that I can do some math and set the VerticalOffset value.

I have added some dependency properties on VerticalOffset and ScrollableHeight through which I can get the events when any of them is changed. Also trying to use them to readjust the VerticalOffset.

Any suggestions or corrections are highly appreciated.

© Stack Overflow or respective owner

Related posts about c#

Related posts about windows-phone-7