Scrollbar autoscroll with specific gap - c#

Sorry, I don't have any codes or markups to show you.
I just want help to get my scroll bar scroll to 10 rows down in a ListView when I drag the thumb button.
For a visualization just take an example of navigation home screen in Android home page. I want to implement exactly same idea in the vertical ListView or any ScrollViewer container.

If you have focus on one item within a ListView, scrolling is automatic.
item.Focus();

Related

How to make axis/index visible always even if scrolled the page far right or far below in Xamarin Forms?

I'm trying to make Xamarin forms application, in which the data should look like this.
However, it can be seen that the height and width of the view are large and I need to scroll the page both horizontally and vertically. So, when I scroll only the data portion should move while the A and B axes stay constant. If I move to column B6 then the view should be as shown below
and from this point if I move row A5 the view should be as shown below.
I'm quite new to xamarin forms or any other android development programming. At this point, I'm just trying to know what kind of search terms that I should use where I can find some documentation related to make such kind of view in my application. I guess a simple idea can be just using a scrollbar but I need my axes points visible all the time even if I scroll far right or far below.
Any suggestions?
Thank you!
To your question, you can search with scrollview, it is a layout that's capable of scrolling its content. You can set the orientation of your scrollview as "both" so it can scroll both horizontally and vertically.
But it can only have one content to scroll. It means scrollView objects should not be nested with other controls that provide scrolling, such as CollectionView, ListView, and WebView. For more information, you can refer to https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/scrollview

WPF ListView scroll whole page (seen items) by button click

I've created a listview in WPF. The items in there are changing their backgroundcolor by clicking, in this case i deactivated the listview prop 'Focusable'.
For my usecase (on a touchscreen) i want to hide the scrollbar and just scroll by clicking an up/down button at the bottom. One click should scroll the whole page (UP/DOWN) and show the next (so far hided) items.
I'm seraching for a flexible solution and don't want to calculate pixels or smth like that (also the items haven't a fixed height, also the window)
Thanks in advance
First off, it might benefit you to take a look at How do I ask a good question?. Specifically, in your case it would be easier to understand the sitution if you included some of your XAML. However, I do think I have a solution for you.
ItemsControls like the ListView support "content scrolling", meaning the ability to scroll by content/items instead of by pixel. This question gives a solution to finding which items are currently visible in the ListView by accessing the internal ScrollViewer. ScrollViewer.VerticalOffset will tell you the index first visible item and ScrollViewer.ViewportHeight will tell you how many items are visible. To scroll to the "next page", you should just need to:
ScrollViewer.VerticalOffset += ScrollViewer.ViewportHeight;

C# Windows Form Scrollbars with multiple containers

I am having difficulty getting both the vertical and horizontal scroll bars to behave as desired in my situation. The page in question has multiple sections that can be expanded and collapsed (only one can be expanded at a time). To try and demonstrate the layout of my page I'm going to use nesting and perhaps a silly naming convention to be as clear as possible:
ucParent
pnlParent
pnl1Title
pnl1
uc1
pnl2Title
pnl2
uc2
pnl3Title
pnl3
uc3-1
uc3-2
uc3-3
And so on. Now, pnlParent has dock=fill, while the child panels are dock=top. All the pnlXTitle panels have buttons that trigger the expanding/collapsing behavior by setting their respective panels directly underneath to enabled=visible=false.
I'm wanting the horizontal and vertical scroll bars to show up as needed when the window is resized and hiding content, however I am not being successful at eliciting this behavior.
With ucParent.AutoScroll=false and pnlParent.AutoScroll=true only the vertical scroll bar is present.
With ucParent.AutoScroll=true and pnlParent.AutoScroll=false neither scrollbar works.
With both ucParent.AutoScroll=true and pnlParent.AutoScroll=true only the vertical scroll bar is present.
In all the above examples, AutoScroll=false for all the other panels and user controls. From what I've read so far, I fear the dock=top setting may be interfering with the horizontal scroll bar behavior. I can force it to display and work by using AutoScrollMinSize, but the panels are of different sizes making this feel like much more of a hack than a proper solution.
Through my searching I found a good number of previous discussions revolving around Windows Forms and scrollbars, but I didn't find anything specific enough I feel I can confidently determine the necessary direction for my application. I would very much appreciate any information you could share that would shed light on why the scroll bars are not working as desired and how that can be remedied.
Thank you!
The problem you're experiencing has to do with the way that docking resizes your controls to fit horizontally within the form.
When you dock a control to the top of its container, it is stretched to fit within the container. Consequently, no part of it falls outside of the container, and there is no need to display the horizontal scroll bar. This is why your scroll bar isn't appearing.
This behavior is by design.

Partially vertically scroll

I have a ListBox that contains two columns - column one contains a Toggle Button, column two contains an Expander with multiple controls within it. If the expander is collapsed, the overall scrolling of the ListBox works fine. However, if the Expander is open and the expander contains a large quantity of items, the ListBox will scroll the entire row size, often not showing part of the expander list.
This would be similar to placing an image in the list box that is larger than the viewable area of the list box. In this case, if you click the scrollbar, you would want to "step" down the image, without it scrolling off the screen in one click.
Is there a setting for the ListBox that will allow the partial scrolling as I've described? My listBox is defined in a xaml, the controls are added via C# code.
Have you tried turning on smooth scrolling by setting ScrollViewer.CanContentScroll to false? This is what controls whether the ScrollViewer will scroll an item at a time, or smoothly with partial items available.
"ScrollViewer currently allows two scrolling modes: smooth
pixel-by-pixel scrolling (CanContentScroll = false) or discrete
item-by-item scrolling (CanContentScroll = true). Currently WPF
supports UI virtualization only when scrolling by item. Pixel-based
scrolling is also called 'physical scrolling' and item-based scrolling
is also called 'logical scrolling'."
(From this answer).
If you have a lot of items in your ListBox, this may not be an ideal solution, however, because it turns off Virtualization, and therefore may have a performance impact. Take a look at this answer to see more about smooth scrolling and virtualization. (One answer suggests a hack that allows for smooth scrolling and virtualization).

Datagrid scrolling in Windows s Mobile way to get rid of scroll bar?

I have a very simple form using the compact framework. I have two search fields a search button and a datagrid. The button sets the DataSource for a DataGrid on the form. I know that I can set the height and width on the DataGrid but I don't want the user to have to use the scroll bars on the DataGrid as it has a few hundred records. I just want the user to use the scroll bar on the form to scroll. How do I accomplish this?
I am assuming that the behavior you want is for a vertical scroll bar that spans the total height of the form to navigate through the records of the DataGrid. This DataGrid does not take up all the space on the form.
You could add a VScrollBar to the side of the form and set its Maximum to the total row count of your DataGrid. Then attach to the ValueChanged event of the scroll bar and manipulate the selected row of your DataGrid. This in effect would be mimicking the scrolling behavior of the DataGrid.
The tricky part is hiding the scroll bar of the DataGrid, as there is no property to hide it. You can extend its width so that the scroll bar is rendered off screen, but remember to set the Form's AutoScroll property to false so that it does not render a Horizontal scroll bar that would reveal the DataGrid kludge.
Based on your application, you may want to look into using a ListView with the View property set to Details. The ListView is much easier to manipulate in the compact framework and might fit your application better. You can still use the same VScrollBar technique above and apply it to the ListView if you wish.
You must get the rowcount from the DataSource. Cast it like the enclosed example to produce the row count: (rsMissingItems is a SqlCEResultSet object)
Dim intRecCnt As Int32 = DirectCast(rsMissingItems.ResultSetView, ICollection).Count

Categories

Resources