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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Disable scrollviewer if there's no scroll because of not enough items and enable it if there are

Thread ID:





132144 Aug 16,2017 01:11 PM UTC Aug 19,2017 11:56 AM UTC UWP 2
Tags: SfDataGrid
Alexandru Pastor Opris
Asked On August 16, 2017 01:11 PM UTC


We've been trying to see if it's possible to have an event or any way to have the scrollviewer disabled when there are not enough items for a scroll and have it enabled once there are. This would avoid a small issue which is that when the datagrid doesn't have enough items it shouldn't catch the scroll event and avoid scrolling on the parent element.

I've created a little sample having a scrollviewer and a list of textblock which exceed the screen on vertical for the scrollviewer to be enabled. If there are a few items in the datagrid and there's no scroll it just catched and disables the parent's scrollviewer, is there any solution to this? One solution would be by adding the properties ScrollViewer.HorizontalScrollMode="Disabled" and ScrollViewer.VerticalScrollMode="Disabled" but that would mean that if there are a lot of items the scroll on the datagrid won't work at all.

Also created a little video to show it.

Have a nice day,

Attachment: SfDataGrid_ScrollViewer_a77dff0b.zip

Gnanasownthari Thirugnanam [Syncfusion]
Replied On August 17, 2017 02:56 PM UTC

Hi Alexandru, 

We have analyzed your query “Few items in SfDataGrid while scroll over the SfDataGrid, ScrollViewer does not scrolled”, Scroll over the SfDataGrid while loaded inside the ScrollViewer manipulation handled by itself(SfDataGrid), so ScrollViewer does not scrolled but you can achieve your requirement by disable the ScrollViewer based on ExtentHeight and ExtentWidth of VisualContainer as like below cod example. 

this.DataGrid1.Loaded += DataGrid1_Loaded; 
private void DataGrid1_Loaded(object sender, RoutedEventArgs e) 
    VisualContainer visualContiner1 = this.DataGrid1.GetVisualContainer(); 
    //checking the DataGrid height and VisualContiner ExtendedWidth (Total number of Row height) 
    if (this.DataGrid1.ActualHeight > visualContiner1.ExtentHeight)             
        visualContiner1.ScrollOwner.VerticalScrollMode = ScrollMode.Disabled;                 
    if (this.DataGrid1.ActualWidth > visualContiner1.ExtentWidth)             
        visualContiner1.ScrollOwner.HorizontalScrollMode = ScrollMode.Disabled; 

We have modified the sample based on your requirement, you can download the same from below mentioned location. 

Sample location: 

Gnanasownthari T. 

Gnanasownthari Thirugnanam [Syncfusion]
Replied On August 19, 2017 11:56 AM UTC

Hi Alexandru,  

You can also achieve your requirement “Few items in SfDataGrid while scroll over the SfDataGrid, ScrollViewer does not scrolled” in another way using IsVerticalRailEnabled and IsVerticalScrollChainingEnabled  attached properties as true like below code example.  

IsVerticalChainingEnabled attached property decides whether the scroll chaining is enabled from Child to its parent. 

<syncfusion:SfDataGrid x:Name="DataGrid1"  
                                       Margin="0, 0, 12, 0" 
                                       ItemsSource="{x:Bind Fields.TestClassList0, Mode=OneWay}"> 
We have modified the sample based on your requirement, you can download the same from below mentioned location.  

Sample location:  
Gnanasownthari T 


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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

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