I try to create a scrollable horizontal StackPanel but I do not succeed very well...
Currently I have my StackPanel with an auto
width (and the problem is maybe here) that contains some items like grids
.
Now, if all my grids are not visibles in the StackPanel (width is too short) I can't scroll.
I already tried to put the StackPanel within a ScrollViewer
but it doesn'
t work too.
How can I fix this?
EDIT here is my code:
<StackPanel Height="85" Margin="0,0,200,15" VerticalAlignment="Bottom">
<ScrollViewer HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Disabled" HorizontalAlignment="Left" Height="85" CanContentScroll="True">
<StackPanel x:Name="Film" Height="85" Width="Auto" Margin="0,0,0,0" Orientation="Horizontal" ScrollViewer.HorizontalScrollBarVisibility="Visible" CanHorizontallyScroll="True" ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.CanContentScroll="True" d:LayoutOverrides="TopPosition, BottomPosition">
<StackPanel.Background>
<SolidColorBrush Color="{DynamicResource ButtonBackground}"/>
</StackPanel.Background>
<Grid Width="100" Background="Red"/>
<Grid Width="100" Background="#FFFF0051"/>
<Grid Width="100" Background="#FFB900FF"/>
<Grid Width="100" Background="#FF002EFF"/>
<Grid Width="100" Background="#FF00FFDC"/>
<Grid Width="100" Background="#FF51FF00"/>
<Grid Width="100" Background="Red"/>
</StackPanel>
</ScrollViewer>
</StackPanel>