Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1240
Determining if Scrollbar is Visible
posted

Is there an easy way, in C#, to find if the vertical and/or horizontal scroll bar is visible?

Thanks

Dan

  • 8576
    Offline posted

    Hi Dan -

    I assume you are talking abou the scrollbars in the XamDataGrid - short of traversing the tree of visual descendants in the XamDataGrid looking for the scrollbars and then checking their Visibility, you should be able to do the following:

    if (this.xamDataGrid1.ScrollInfo.ViewportWidth > this.xamDataGrid1.ScrollInfo.ExtentWidth)

    Debug.WriteLine("Horizontal Scrollbar is NOT visible");

    else

    Debug.WriteLine("Horizontal Scrollbar is visible");

    if (this.xamDataGrid1.ScrollInfo.ViewportHeight > this.xamDataGrid1.ScrollInfo.ExtentHeight)

    Debug.WriteLine("Vertical Scrollbar is NOT visible");

    else

    Debug.WriteLine("Vertical Scrollbar is visible");

     Joe