I've created开发者_运维百科 a UserControl
that contains a ScrollViewer
panel that contains a data bounds ItemsControl
. When I add this UserControl
into a Grid
's cell in the parent Window
, the ScrollViewer
expands to contain all of the items in the ItemsControl
rather than constraining to the dimensions of the cell. Because of this, it won't scroll the items.
A little more code would be helpful to see exactly what you are doing...
One thing to check is the "HorizontalScrollBarVisibility" (or "VerticalScrollBarVisibility" depending on orientation) property of the ScrollViewer, it should default to "Auto", but in your user control this may be getting overridden at a higher level in the visual tree; try setting it explicitly:
<ScrollViewer VerticalScrollBarVisibility="Auto">
I figured it out. I had my layout a little bit messed up. Somehow I had a ListBox
inside a ScrollView
and so the two ScrollViewers
messed each other up.
Sorry; WPF is very new to me. Still getting a feel for it.
精彩评论