Back to Devexpress

TableView.CustomScrollAnimation Event

wpf-devexpress-dot-xpf-dot-grid-dot-tableview-b8fbb51c.md

latest5.7 KB
Original Source

TableView.CustomScrollAnimation Event

Enables you to provide custom animation played when grid data is vertically scrolled (per-pixel).

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public event CustomScrollAnimationEventHandler CustomScrollAnimation
vb
Public Event CustomScrollAnimation As CustomScrollAnimationEventHandler

Event Data

The CustomScrollAnimation event's data class is DevExpress.Xpf.Grid.CustomScrollAnimationEventArgs.

Remarks

The TableView.AllowPerPixelScrolling option must be set to true , and the TableView.ScrollAnimationMode property must be set to ScrollAnimationMode.Custom.

Example

This example shows how to implement a custom animation displayed when a user vertically scrolls the GridControl (per-pixel scrolling):

  1. Set the TableView.AllowScrollAnimation property to true.
  2. Set the TableView.ScrollAnimationMode property to Custom.
  3. Handle the TableView.CustomScrollAnimation event and specify a custom scroll animation.

View Example: Implement Custom Scroll Animation

xaml
<dxg:GridControl Name="grid" AutoGenerateColumns="AddNew">
    <dxg:GridControl.View>
        <dxg:TableView Name="view"
                       AutoWidth="True"
                       AllowScrollAnimation="True"
                       ScrollAnimationMode="Custom"
                       CustomScrollAnimation="view_CustomScrollAnimation"/>
    </dxg:GridControl.View>
</dxg:GridControl>
cs
void view_CustomScrollAnimation(object sender, DevExpress.Xpf.Grid.CustomScrollAnimationEventArgs e) {
    e.Storyboard = new Storyboard();
    DoubleAnimation animation = new DoubleAnimation {
        From = e.OldOffset,
        To = e.NewOffset,
        Duration = new Duration(TimeSpan.FromMilliseconds(600)),
        EasingFunction = new ExponentialEase() { Exponent = 0 }
    };
    e.Storyboard.Children.Add(animation);
}
vb
Private Sub view_CustomScrollAnimation(ByVal sender As Object, ByVal e As DevExpress.Xpf.Grid.CustomScrollAnimationEventArgs)
    e.Storyboard = New Storyboard()
    Dim animation As DoubleAnimation = New DoubleAnimation With {.From = e.OldOffset, .[To] = e.NewOffset, .Duration = New Duration(TimeSpan.FromMilliseconds(600)), .EasingFunction = New ExponentialEase() With {.Exponent = 0}}
    e.Storyboard.Children.Add(animation)
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomScrollAnimation event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-data-grid-implement-custom-scroll-animation-for-per-pixel-scrolling/CS/DXGrid_CustomScrollAnimation/MainWindow.xaml#L12

xml
ScrollAnimationMode="Custom"
                   CustomScrollAnimation="view_CustomScrollAnimation"/>
</dxg:GridControl.View>

wpf-data-grid-implement-custom-scroll-animation-for-per-pixel-scrolling/CS/DXGrid_CustomScrollAnimation/obj/Debug/net8.0-windows/MainWindow.g.cs#L101

csharp
#line 12 "..\..\..\MainWindow.xaml"
this.view.CustomScrollAnimation += new DevExpress.Xpf.Grid.CustomScrollAnimationEventHandler(this.view_CustomScrollAnimation);

wpf-data-grid-implement-custom-scroll-animation-for-per-pixel-scrolling/VB/DXGrid_CustomScrollAnimation/obj.NetFX/x86/Debug/MainWindow.g.vb#L100

vb
#ExternalSource("..\..\..\MainWindow.xaml",12)
AddHandler Me.view.CustomScrollAnimation, New DevExpress.Xpf.Grid.CustomScrollAnimationEventHandler(AddressOf Me.view_CustomScrollAnimation)

See Also

TableView Class

TableView Members

DevExpress.Xpf.Grid Namespace