0

I have a xaml page that has a grid with two listbox inside. I want the grid to scroll through the listboxes and this is working, but only if I scroll from outside the listbox area. I want the listboxes to propagate the scroll to the grid, as themselves does not have any scrolling bar.

This is my code:

<ScrollViewer>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <ListBox BorderBrush="Red" BorderThickness="2" Grid.Row="0" ItemsSource="{Binding Path=PinpadPaymentBrandControlList, ElementName=PbUserControl}" x:Name="RadioPbList"
             ScrollViewer.HorizontalScrollBarVisibility="Disabled"
             SelectionMode ="Single"
             SelectionChanged="RadioPbList_SelectionChanged">

            <ListBox.ItemTemplate >
             ...
            </ListBox.ItemTemplate >
        </ListBox>

        <ListBox BorderBrush="Red" BorderThickness="2" Grid.Row="0" ItemsSource="{Binding Path=PinpadPaymentBrandControlList, ElementName=PbUserControl}" x:Name="RadioPbList"
             ScrollViewer.HorizontalScrollBarVisibility="Disabled"
             SelectionMode ="Single"
             SelectionChanged="RadioPbList_SelectionChanged">

            <ListBox.ItemTemplate >
             ...
            </ListBox.ItemTemplate >
        </ListBox>
    </Grid>
</ScrollViewer>

I tried using the ScrollViewer.CanContentScroll="True" in the ListBox tag, but it didn't work either. Any help? I'm not used to using xaml so I might be doing it pretty much wrong

Marcelo Abiarraj
  • 199
  • 3
  • 18
  • Have you tried this: https://stackoverflow.com/questions/1585462/bubbling-scroll-events-from-a-listview-to-its-parent ? – fmilani Mar 01 '18 at 14:24
  • No, I wanted to solve this using pure xaml, I don't know if it is possible, though – Marcelo Abiarraj Mar 01 '18 at 14:27
  • 1
    Somethings can only be done with code-behind, I guess, like the bubbling of events – fmilani Mar 01 '18 at 14:36
  • Maybe you're right @fmilani, I'll try using the code-behind, thank you very much for the answer – Marcelo Abiarraj Mar 01 '18 at 14:48
  • ListBoxes have scrollviewers built into their template. I must not be understanding the desired effect. Are you wanting for say a listbox to scroll, hit the end, then parent to scroll to next listbox where then it's scrollviewer takes over? – Chris W. Mar 01 '18 at 15:23

0 Answers0