This is a migrated thread and some comments may be shown as answers.

Detect if scrollbar is visible

6 Answers 180 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Håkan
Top achievements
Rank 1
Håkan asked on 14 Dec 2012, 10:01 AM
Hi!

Is there anyway I can detect if a scrollbar in a GridView is visible or not if property is set to Auto?

Regards
Håkan

6 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 14 Dec 2012, 10:06 AM
Hello,

Using the ChildrenOfType<> extension method , you can find the GridViewScrollViewer. Somtehing like : 

this.RadGridView1.ChildrenOfType<GridViewScrollViewer>();

All the best,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Håkan
Top achievements
Rank 1
answered on 14 Dec 2012, 10:42 AM
Hi,

I have done that already, but I can't seem to find any suitable property on it.

I'm doing this when the collection in my view model changes.
Tried to check if ExtentHeight is larger than ViewportHeight but sometimes it it larget even thought the scrollbar is not visible.
That happens if you remove items until the scrollbar is hidden.

Regards,
Håkan
0
Pavel Pavlov
Telerik team
answered on 14 Dec 2012, 01:23 PM
Hello,

The ScrollViewer has  viewport height and extent height .If the extent is larger than the viewport - > a scroll bar appears.

Regards,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Håkan
Top achievements
Rank 1
answered on 17 Dec 2012, 07:15 AM
Hi Pavel.

I'm doing as you say, but it seems to be in the wrong place.
I do the check in the CollectionChanged event.

My grid fits 10 records so the scrollbar appears when adding the 11:th.
But at that point the ExtentHeight is 260 and the ViewportHeight is 261, so it seems the 11:th record is not added to the grid at this point.

If I remove the 11:th record, the ExtentHeight is 286, so that meend it's still in the grid at this point.

Is there a better place to do the check, when the grid is actually updated after the CollectionChanged event?

Regards,
Håkan

0
Accepted
Pavel Pavlov
Telerik team
answered on 17 Dec 2012, 09:07 AM
Hello,

You may try to perform the extent/viewport check in the LayoutUpdated event of RadGridView.

Kind regards,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Håkan
Top achievements
Rank 1
answered on 18 Dec 2012, 07:09 AM
That worked fine, thank you!

- Håkan
Tags
GridView
Asked by
Håkan
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Håkan
Top achievements
Rank 1
Share this question
or