Articles in this section
Category / Section

How to apply animation for the selected rows in Xamarin.Android DataGrid?

1 min read

SfDataGrid provides support to select one or more rows either programmatically or by touch interactions. By default SfDataGrid does not apply any animation for the selected rows. However it provides extensibility to apply animation for the selected rows by writing a custom SelectionController derived from GridSelectionController and assigning it to the SfDataGrid.SelectionController property. You can override the SetSelectionAnimation () method in which you will get the selected row element as an argument. Thus you can apply animation for the selected row(s) in runtime based on your requirement.

Refer the following code example that explains how to apply a simple Alpha animation to the selected row.

sfGrid.SelectionController = new CustomSelectionController(sfGrid);
sfGrid.SelectionMode = SelectionMode.Multiple;

 

public class CustomSelectionController : GridSelectionController
{
    public Color[] SelectionColors { get; set; }
 
    public CustomSelectionController(SfDataGrid datagrid)
    {
        this.DataGrid = datagrid;
        SelectionColors = new Color[5] { Color.Red, Color.Blue, Color.Black, Color.Gray, Color.MediumPurple };
    }
 
    public override Color GetSelectionColor(int rowIndex, object rowData)
    {
        if (SelectionColors != null)
            return SelectionColors[rowIndex % 7];
        else
            return Color.Blue;
    }
 
    protected override void SetSelectionAnimation(VirtualizingCellsControl rowElement)
    {
        //Alpha animation
        rowElement.Alpha = 0.5f;
        rowElement.Animate().Alpha(0.5f).SetDuration(30000).AlphaBy(1f).WithEndAction(new Runnable(() =>
        {
          rowElement.Alpha = 1f;
        }));
    }
}

 

Refer the following screenshot that shows the final outcome upon execution of the above code.

wpf grid selection

 

Conclusion

I hope you enjoyed learning how to apply animation for the selected rows in Xamarin.Android DataGrid.

You can refer to our Xamarin.Android DataGrid feature tour page to know about its other groundbreaking feature representations. You can also explore our Xamarin.Android documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied