Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scroll bar, if Items exceed inside itemControl

Tags:

c#

.net

wpf

I have ItemControl

It displays one panel for each record inside ObservableCollection.

My Problem is….

When size of ObservableCollection increase window can’t accommodate more panels so it displays only first six panels.

So criteria, One panel for each record inside ObservableCollection,couldn't be accomplish.

So, I need to have scroll bar so I can access each panel. How does it can be implement?

See one screen shot below and Code of It Here

enter image description here

Thanks......

like image 333
Pritesh Avatar asked Dec 20 '25 22:12

Pritesh


1 Answers

You need to host your panel within a ScrollViewer. This allows it to grow beyond the space available to it, whilst the ScrollViewer adds a Scrollbar.

You can do this by modiyfing the ItemsControl template:

<ItemsControl>
  <ItemsControl.Template>
    <ControlTemplate>
     <ScrollViewer>
       <ItemsPresenter/>
     </ScrollViewer>
   </ControlTemplate>
  </ItemsControl.Template>
</ItemsControl>
like image 141
ColinE Avatar answered Dec 22 '25 10:12

ColinE



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!