Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable scrollbar / scrolling on a WPF Datagrid

I've got a DataGrid control that's within a Grid layout container, and I can't seem to get the auto-scroll on the DataGrid itself to work. I can wrap the DataGrid around a ScrollViewer and thus adding the scroll bar, but the auto scrolling doesn't work.

So right now, when new entries are added to the DataGrid, the DataGrid just expands vertically. I'd like to have the vertical scroll bar enabled allowing scrolling to the items in the DataGrid when more items are added than the original vertical size can show, instead of the whole DataGrid expanding. Surely there's got to be an easy way to make that happen.

like image 851
BrianP Avatar asked Aug 09 '10 20:08

BrianP


People also ask

How to enable the horizontal scroll bar in WPF DataGrid (sfdatagrid) groupdroparea?

How to enable the hori... How to enable the horizontal scroll bar in WPF DataGrid (SfDataGrid) GroupDropArea? The scroll bar for GroupDropArea is disabled in WPF DataGrid (SfDataGrid). To enable the horizontal scroll bar in GroupDropArea, the default style of ScrollViewer for GroupDropArea can be customized with ScrollbarVisibility as true.

How do I add a scrollbar to a datagridview?

GridView still have not ScrollBars property. To create GridView with horizontal or vertical scrollbar you need to place GridView inside <div > tag or inside Panel control. Please Sign up or sign in to vote. you are making the DataGridViewControl disabled for any operation.To use the scroll bar you can try the following other options.

What is the default scrollmode in radgridview?

By default the ScrollMode property is set to the RealTime mode. There is also an option to implement programmatic scrolling. To learn more read the Scroll to a particular row or column article. When RadGridView's ScrollMode is set to Deferred, a small tooltip appears when scrolling which previews the current scroll position.

What is the difference between realtime and deferred scroll mode?

RealTime: Updates the content in view in real time as the user scrolls. Deferred: Keeps the content in view static until scrolling is complete. By default the ScrollMode property is set to the RealTime mode. There is also an option to implement programmatic scrolling. To learn more read the Scroll to a particular row or column article.


1 Answers

Okay, got this one figured out ... It turns out I didn't even need to wrap the datagrid around a ScrollViewer after all. All I had to do is define the height for the datagrid (Using the "Height" attribute) and the datagrid scroll bar appears when items are added that go beyond the height. Apparently when the height isn't defined it is dynamic and expands vertically as new items are added.

Another thing to add to this was that in my datagrid, I had a row details defined for each row as well, so when multiple row details were expanded, the scrolling would be enabled, but the scroll bar behavior was a little wacky (Like it wasn't smooth scrolling), and the fix for that to make it smooth scrolling was adding the following datagrid attribute: ScrollViewer.CanContentScroll="False" (I'm guessing the datagrid control is/inherits from a ScrollViewer) and then the scrolling was smooth and like the normal expected scrolling behavior.

like image 189
BrianP Avatar answered Sep 21 '22 07:09

BrianP