user380719
user380719

Reputation: 9903

How can I add scrolling to an ItemsControl?

I'd like to show items in an ItemsControl in 3*4 pages One cool feature is that I can change the ItemsPanel of an ItemsControl:

for example:

<ItemsControl>
  <ItemsControl.ItemsPanel>
    <ItemsPanelTemplate>
      <UniformGrid Column='3' Row ='4'/>
...

How can I enable scrolling though? If the panel is a StackPanel, scrolling/paging is enabled. But not for UniformGrid

Upvotes: 1

Views: 1975

Answers (2)

rw_
rw_

Reputation: 106

Could use Template instead and put the ScrollViewer inside the ItemsControl and use it for the presentedcontent - this way the content is contained in the scroller not the entire ItemsControl.

<ItemsControl>
   <ItemsControl.Template>
      <ControlTemplate>
         <ScrollViewer>
            <ItemsPresenter />
          </ScrollViewer>
       </ControlTemplate>
    </ItemsControl.Template>
</ItemsControl>

Upvotes: 1

Kent Boogaart
Kent Boogaart

Reputation: 178630

It's unclear whether you want paging or scrolling, but I think you mean the latter. That being the case, simply place the ItemsControl in a ScrollViewer:

<ScrollViewer>
    <ItemsControl ...>
    </ItemsControl>
</ScrollViewer>

Upvotes: 2

Related Questions