Show only full items on the stack

I have a slider that consists of a grid:

  • ScrollViewer
  • Stackpanel (the stack panel is inside the viewer)

The slider has 2 navigation buttons to view the selected items.

But how can I only show complete items? Currently, some buttons are only half displayed because there is no more free space. In the final version, only 5 buttons should be displayed at once. But if a specific event is triggered, more buttons will be displayed for buttons.

For example 1-5 are visible. If another button appears, only 2-6 should be visible.

The buttons inside the slider should be dynamically created. Does it make sense to stick to the stack panel? The reason is that the buttons are static.

EDIT: When dynamically adding buttons to the stack, how exactly does this work for already configured buttons? I can add a normal button just fine, but I want to add the buttons already done below.

enter image description here

+3


source to share


1 answer


I believe VirtualizingStackPanel

(with virtualization enabled by default) can only do item-based scrolling (as opposed to pixel-based scrolling). It might be worth trying replacing StackPanel

with VirtualizingStackPanel

to fix this problem.



0


source







All Articles