We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Scroll to horizontal offset in datagrid

Thread ID:

Created:

Updated:

Platform:

Replies:

108370 Apr 16,2013 07:29 PM UTC Apr 24,2013 09:12 AM UTC WinRT 3
loading
Tags: SfDataGrid
Gary Pansino
Asked On April 16, 2013 07:29 PM UTC

How do you do the equivalent of ScrollViewer.ScrollToHorizontalOffset(##) for a data grid?

I have successfully used the .ScrollColumnIntoView(col#) command, but when combined with a frozen first column in snapped view, the datagrid scrolls to the column and cuts off the leftmost portion of the target column, so I need more precision.

Thank you.



Prakash Selvaraj [Syncfusion]
Replied On April 17, 2013 07:03 AM UTC

Hi Gary,

 

We have analysed your query, you can achieve your requirements by getting the ScrollableContentViewer from VisualTreeHelper, and then you can directly use the ScrollToHorizontalOffset method from ScrollableContentViewer object.

Please refer the following code snippet.

Code Snippet [C#]:

void MainPage_Loaded(object sender, RoutedEventArgs e)

{

    scrollViewer = FindDescendant(datagrid, typeof(ScrollableContentViewer)) as ScrollableContentViewer;

    scrollViewer.ScrollToHorizontalOffset(offset);

}

 

DependencyObject FindDescendant(DependencyObject startingFrom, Type typeDescendant)

{

    DependencyObject visual = null;

    var iCount = VisualTreeHelper.GetChildrenCount(startingFrom);

    for (var i = 0; i < iCount; ++i)

    {

        var child = VisualTreeHelper.GetChild(startingFrom, i);

        if (typeDescendant == child.GetType())

        {

            visual = child;

            break;

        }

        visual = FindDescendant(child, typeDescendant);

        if (visual != null)

            break;

    }

    return visual;

}

 

 

 

Please let us know if you need further assistance

 

Regards,

Prakash S.                                                                                     


Gary Pansino
Replied On April 17, 2013 04:22 PM UTC

Works perfectly ... thanks.

Prakash Selvaraj [Syncfusion]
Replied On April 24, 2013 09:12 AM UTC

Hi Gary,

Thank you for your feedback, please let us know if you have any concerns.

Regards,

Prakash S.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;