Need to build image explorer with expanders, but I have some problem with scrolling. I have ItemsControl with ListBox inside, scroll do not work when mouse on ListBox. Here is xaml:
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Grid.Row="1" Background="{DynamicResource LightGrayBackgroundBrush}" >
<ItemsControl x:Name="itmsControl" DataContext="{Binding ElementName=_self}" ItemsSource="{Binding ImagesSource}" Margin="15" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid x:Name="grdIn">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" MinHeight="25"/>
<RowDefinition x:Name="grd1"/>
</Grid.RowDefinitions>
<Expander Grid.Row="1" IsExpanded="True" BorderThickness="0" Background="White">
<Expander.Header>
<Border Background="White" BorderBrush="White" Height="40">
<TextBlock Text="{Binding Date}" Background="White" FontSize="14" Foreground="Gray" FontWeight="Bold" VerticalAlignment="Center" Margin="10,0,0,0"/>
</Border>
</Expander.Header>
<ListBox ItemsSource="{Binding ImageList}" ItemContainerStyle="{DynamicResource ImageListBoxItemStyle}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" SelectionMode="Extended" Background="Transparent" SelectionChanged="ListBox_SelectionChanged" PreviewKeyDown="OnKeyDownHandler" MouseDown="ListBox_MouseDown" ScrollViewer.CanContentScroll="False">
<ListBox.ItemTemplate>
<DataTemplate>
<Image Stretch="UniformToFill" Width="{Binding Width}" Height="{Binding Height}" Source="{Binding Source}" Margin="3" MouseDown="Image_MouseDown"/>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</Expander>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
When you select Listbox image, focus is lost for scroll viewer. So, you can set focus to scroll viewer on MouseWheel/PreviewMouseWheel event or you can scroll manually like below.
change xaml with this:
Do you want to scroll ScrollViewer only? Then why do you use ListBox inside ItemsControl? I watch that you block scrolling of ListBox
But ListBox has ScrollViewer inside his template. And I think that this ScrollViewer handle "mouse whell" event and it does not reach the root ScrollViewer. I think that you can fix your problem if you just replace ListBox to ItemsControl.