3
votes

I have a slider which consists of grid of:

  • Scrollviewer
  • Stackpanel (the stackpanel is located inside the viewer)

The slider has 2 navigation buttons to browse trough the selected items.

But how can i only show complete items? Currently some buttons only get shown in half because there is no more space available. In the final version only 5 buttons should be shown at once. But if a certain event is fired more buttons will be visible for.

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

The buttons inside the slider have to be created dynamically. Does it make sense to stick with stack panel? Cause at the moment the buttons are static.

EDIT: When adding buttons dynamicly to the stackpanel how exactly does this work for already custom made buttons? I can add a normal button just fine but i wish to add the buttons already made below.

enter image description here

1
Doubt this helps here but I have noticed in a ComboBox or ListBox if it only displays a TextBlock then it keeps it whole. But a more complex control like a button will get cut. - paparazzo
Can you add some code to show how they're being generated in the first place? XAML databinding code would help also. - Steve Danner
Currently the buttons are not being generated dynamically yet. But the problem is i am not really sure what control to take for this sort of approach. In what sort of control should the 5 buttons be displayed? - Rakr
You could cheat and manually set the width of the stackpanel. SizeOfButton * 5... You would have to listen for window resize events. - patrick

1 Answers

0
votes

I believe the VirtualizingStackPanel (with virtualisation turned on as it is by default) can only perform item-based scrolling (as opposed to pixel-based scrolling). It might be worth trying swapping the StackPanel for a VirtualizingStackPanel to see if that fixes your problem.