Listbox scrollbar thumb changes size when content is variable height

后端 未结 3 514
轻奢々
轻奢々 2021-01-06 01:52

I have a ListBox with many objects displayed, each of which can be a variable height, based on the number of values each object has. See my previous question that was answer

相关标签:
3条回答
  • 2021-01-06 02:30

    Disable virtualization or make the items in your ListBox all of equal height. If you've got less than 100 items or so, you can live without the virtualization.

    0 讨论(0)
  • 2021-01-06 02:31

    Set ScrollViewer.CanContentScroll="False" on the ListBox, this will disable what's called "logical scrolling", which does scrolling based on item count instead of height ("physical scrolling").

    0 讨论(0)
  • 2021-01-06 02:42

    Why not switch off any size restrictions on the ListBox itself, let it size to contents and wrap it into a ScrollViewer, setting a proper size for the latter?

    The markup should look like the following:

        <ScrollViewer Width="640px" Height="480px">
            <ListBox>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <!--Visualization of a list item-->
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </ScrollViewer>
    

    I saw no thumb size changings during scrolling if it was implemented this way.

    0 讨论(0)
提交回复
热议问题