'VirtualizingPanel.ScrollUnit="Pixel" doesnt work and change scrolling to smooth for listbox in .NET 4.7.2 wpf
I am interested in smooth (pixel) scrolling of ListBox but I don't want to use ScrollViewer.CanContentScroll="False" because it does not allow to virtualise ListBox view. I have read that starting by .NET 4.5 it is possible to use VirtualizingPanel.ScrollUnit="Pixel" which allows both virtualising and smooth scrolling, however it doesn't change the behaviour of my scrolling
Here is the code of the listBox (orientation is horizontal)
<ListBox Name="FilmsListBox" Grid.Row="1" Margin="50 25 50 30" HorizontalAlignment="Center" ScrollViewer.HorizontalScrollBarVisibility="Visible" VirtualizingPanel.ScrollUnit="Pixel" VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling" ScrollViewer.CanContentScroll="True" Background="Transparent" BorderBrush="Transparent" Style="{DynamicResource TransparentListBox}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<DockPanel Grid.Row="0" Margin="30" Width="125" Height="200" VerticalAlignment="Top" HorizontalAlignment="Stretch">
<Border BorderThickness="1.2" BorderBrush="#FF715C4E">
<Image Name="FilmPosterImage" Stretch="UniformToFill" Source="Images/eternals_default.jpg"></Image>
</Border>
</DockPanel>
<TextBlock Grid.Row="1" Margin="10 0 10 25" TextWrapping="Wrap" TextAlignment="Center" HorizontalAlignment="Center" Name="FilmTitleTextBlock" FontFamily="Calibri" FontSize="22" Initialized="FilmTitleTextBlock_Initialized">Вечные (18+)</TextBlock>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Please help with some alternatives or explain why the expected tool as VirtualizingPanel.ScrollUnit doesn't behave properly
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
