How can i make smooth scrolling of content into ListBox? I tried to use ListBox.ScrollIntoView but it instantly scrolls to selected item.
A:
You can use an animation to achieve that goal - unfortunately the scrolling Horizontal/VerticalOffset cannot be animated directly so you have to animate properties on a mediator object, which then in turn sets the desired values.
There's a full article about this approach here.
<ScrollViewer x:Name="MyScroller">
<ScrollViewer.Resources>
<Storyboard x:Name="ScrollAnimation">
<!-- Animate from top to bottom -->
<DoubleAnimation x:Name="VerticalOffsetAnimantion"
Storyboard.TargetName="Mediator"
Storyboard.TargetProperty="VerticalOffset"
Duration="0:0:1">
<DoubleAnimation.EasingFunction>
<!-- Ease in and out -->
<ExponentialEase EasingMode="EaseInOut"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</ScrollViewer.Resources>
BrokenGlass
2010-10-26 13:23:22