Home > Net >  Incremental ListView with ScrollBar
Incremental ListView with ScrollBar

Time:05-31

I want to implement a ListView that loads new content when is scrolled (it will have over 2000 elements) with a scrollbar. This is what I have:

<ListView
   Width="500"
   MaxHeight="400"
   IsItemClickEnabled = "False"
   SelectionMode ="None"
   IncrementalLoadingThreshold="5"
   IncrementalLoadingTrigger="Edge"
   ScrollViewer.VerticalScrollBarVisibility="Visible"
   ScrollViewer.VerticalScrollMode="Enabled"/>

The list works perfectly fine but the scrollbar is not visible. How can I make it work?

CodePudding user response:

there is another way to go. you can use "ScrollViewer" and "Stackpanel" as main content of "ScrollViewer". then set the "Orientation". finally add list itmes as childrens of "Stackpanel" please take a look at sample:

<ScrollViewer
        Width="500"
        MaxHeight="400"
        VerticalScrollBarVisibility="Visible"
        VerticalScrollMode="Enabled"
        >
        <StackPanel Orientation="Vertical" SizeChanged="items_modified_event">
            <ListViewItem Content="item1" />
            <ListViewItem Content="item2" />
            <ListViewItem Content="item3" />
            <ListViewItem Content="item4" />
            .
            .
            .
            .
        </StackPanel>           
    </ScrollViewer>

CodePudding user response:

The problem was with a fixed with. After removing it, the scrollbar is visible.

  • Related