Scollbars in dynamic content ItemsControl fix

79 views
Skip to first unread message

Marlon Grech

unread,
Nov 18, 2008, 1:31:24 PM11/18/08
to wpf-di...@googlegroups.com
Hey guys,

I just posted a post on how to fix scrollbars with ItemsControls that have a Dynamic Layout.
http://marlongrech.wordpress.com/2008/11/18/fix-scrollbars-for-a-dynamic-layout-in-a-listviewlistbox/

Yet I must admit I don't really understand why this happens. I mean I can understand why the scrolling behaves strange in such a scenario but why setting the attached property ScrolViewer.CanContentScroll=False fixes this is still magic for me... Any idea?

--
Regards
Marlon
WPF Blog - http://marlongrech.wordpress.com/

Andrew

unread,
Nov 18, 2008, 1:38:41 PM11/18/08
to wpf-di...@googlegroups.com
Wouldn't that cause the scrollviewer to measure the itemshost panel with infinity and therefore lose any virtualization because you're basically causing the itemspanel to size to the content and have the scrollviewer implement the scrolling rather than delegate to the itemspanel's IScrollInfo impl?

From: Marlon Grech <marlo...@gmail.com>
To: wpf-di...@googlegroups.com
Sent: Tuesday, November 18, 2008 1:31:24 PM
Subject: [WPF Disciples] Scollbars in dynamic content ItemsControl fix

Marlon Grech

unread,
Nov 18, 2008, 1:47:28 PM11/18/08
to wpf-di...@googlegroups.com
I don't think that this has anything to do with Virtualization because I tried setting a StackPanel as ItemsPanel to the ListView to check if it was because of Virtualization, but this did not change anything. I am really confused... I have no idea how this attached property is fixing this!

Andrew

unread,
Nov 18, 2008, 2:11:42 PM11/18/08
to wpf-di...@googlegroups.com
Well its not directly related to virtualization but what I'm saying is that you will lose virtualization. If you snoop on your listview after setting CanContentScroll, I suspect that you will find that the ItemsPanel is no longer just the size of visible area of the ListView - instead it is the size required to show all the items (regardless of what's in view) because the scrollviewer is doing the scrolling which knows nothing about the items - just the size that the itemspresenter (i.e. the itemspanel it contained) reported it wanted to be if it had all the room (i.e. infinity).
Sent: Tuesday, November 18, 2008 1:47:28 PM
Subject: [WPF Disciples] Re: Scollbars in dynamic content ItemsControl fix

Marlon Grech

unread,
Nov 18, 2008, 2:14:50 PM11/18/08
to wpf-di...@googlegroups.com
Yea, ok now I am understanding better. I think that this is totally acceptable in my case. I will edit the post to say that this solution will drop the Virtualization support. Thanks dude :)
Reply all
Reply to author
Forward
0 new messages