How do i make a ScrollViewer with buttons instead of scrollbar? - c#

I'm making an online cinema UWP app and i need to implement horizontal "gallery" with movies. The app will be used on PC, Xbox and touch devices, so i need the scrolling to be working with mouse, arrow keys and touch scrolling with swipes.
Currently I'm using ListView with ScrollViewer, but it doesn't give me the intended result. I want mouse wheel to scroll vertically, but when pointer enters the area of ListView, it starts to scroll the View horizontally. Disabling horizontal scrolling, well, breaks everything, so this pure implementaion is not an option.
I like the way MS made horizontal gallery in Microsoft Store app. It's scrollable with touch swipes and keyboard, but mouse wheel does nothing. Instead, the view shows round arrow buttons on the sides of this horizontal list like this:
I want to make something like that, but can't find any tips for controlling the scroll manually. Maybe there's any similar controls I don't know about or docs for making such control?

It should not be a big deal.
Set the VerticalScrollMode="Disabled" , VerticalScrollBarVisibility="Disabled", HorizontalScrollMode="Auto" and HorizontalScrollBarVisibility="Auto". Then set those two buttons to left and right with vertically centered alignment.
Use the ChangeView Method in the Click event handler to programmatically scroll through the contents. That's it.

Related

How can I prevent to one finger scrolling for listview control in uwp?

I want to enable just two finger scrolling. I am developing uwp application on windows 10.How can I prevent to one finger scrolling for listview control in uwp?
Bests
You could probably do that, but I won't help you since that would be an evil feature that would confuse the users of your app. Instead, you should consider alternative solutions to whatever you'd like to happen when users use a single finger in a ScrollViewer.
Note that you're essentially trying to change how the ScrollViewer in the ListView template behaves. In most cases, you do that when you want to drag an item out of a list. Most people either handle the press and hold (aka long holding - the Holding event) or a cross-drag (dragging perpendicular to the ScrollViewer panning direction) and call ScrollViewer.CancelDirectManipulations() to stop panning and handle drag & drop instead.
If you just want a single finger panning to stop working - then you should not do that.

How can I allow a user to pan a map within a ListView in Xamarin.Forms?

I'm writing a survey-style app in Xamarin.Forms in which I have numerous question types displayed in a ListView. For example, a single ListView would contain several cells that show either an Entry (text box), a Picker (combobox), or a Switch (checkbox).
In one question type, I ask the user whether their current GPS position is accurate relative to some landmark. To help them gauge the accuracy, I display a map within the cell itself. The issue I'm running into is that the user is unable to scroll the map vertically because Xamarin.Forms seems will scroll the entire ListView instead of just the map. Horizontal scrolling on the map seems to work fine, but as soon as a slight vertical motion is detected the ListView begins to move.
Is there a way to prevent the ListView from scrolling when the user is attempting to pan the map itself? Perhaps a way for the map to intercept the touch event?
You can try to create a custom renderer for the ListView and disable it's scroll upon panning the map.
Here is the information about custom renderers:
https://developer.xamarin.com/guides/xamarin-forms/custom-renderer/
for android, check this post:
http://forums.xamarin.com/discussion/37835/disable-scrollview-scrolling-on-android
for iOS, check this post:
https://forums.xamarin.com/discussion/56318/scrollview-horizontal-completely-disable-vertical-scroll

How to scroll by touch custom control?

I have a custom control in a winforms C# application which looks like this:
PANEL
-label1
-label2
-label3
If I want to scroll with the mouse wheel, scrolls fine, even if I have the mouse over one of those labels. The problem comes when I want to scroll touching the screen.
If I touch the panel it scrolls just fine, but it doesn't if I touch over a label.
ps: actually labels are custom controls too.

C# focus shifting

I am trying to enable scrolling on a picturebox. I have everything working except for one nagging little detail. The focus shifts in an inexplicable way to the wrong scroll bar with the first click of the arrow key. The picture box has two scrollbars which become visible when the picture being displayed is too large. If the picture fits inside the box no scrollbars show and the vertical arrow keys behave the same as page up/down keys.
On the mouse-down event over the picture box I set the focus to the picture box object so the user can scroll with the mouse wheel. The user can then move the image one of three ways. They can click and hold and drag it up/down/right/left, or they can scroll with the mouse wheel vertically or they can use the arrow keys to scroll in all four direction. If they use the arrow keys I check PreviewKeyDownEvent on the scroll bars for which key and if it is an up/down or right/left arrow key I set the focus on either the horizontal or vertical scroll bar.
The problem is (I see this in the debugger) that when the down key is pressed (as an example) the PreviewKeyDownEvent handler runs and sets the focus (verticalBar.Focus() in this case) I see the focus shift to the vertical scroll bar, but as soon as the scope leaves the event handler it shifts to the opposite scroll bar (horizontal in this case)
I am writing a form into a third party application so I could see focus going to some default control being caused by some outside function. The odd thing is that it always goes to the opposite scroll bar from what I just set; vertical if I want horizontal and horizontal if I want vertical. Once the focus is on either scroll bar a second click on the an arrow key will shift the focus to the correct scroll bar and things will then work appropriately after that.
If the focus is already ON one scroll bar or the other it will work as expected. Focus will shift back and forth between them appropriately. But if focus starts on the picture box it will always be set to the wrong bar on the first click.
I am new to C# and GUI stuff in general so any advice will be much appreciated.
thanks

Bigger mouse cursor in Silverlight

I have a silverlight application in which I have to click on some pictures, if I hover over them for 3 seconds approx.
The problem is that if the pictures are a bit small in size, and the mouse moves a little, it moves out of the respective picture clicking area and selects another picture.
I have tried using a custom image in place of the default mouse cursor, but can this mouse be enlarged in some way so that it has a larger clicking area under it and not only the tip of the mouse pointer?
I think you're thinking about this the wrong way around. The mouse pointer simply defines a coordinate on the screen, rather than an area. If you want mouseover/click etc to be more generous, and give a wider area of interaction, you should make the target area larger.
So in the case of some small image, you can surround it with a larger area to handle the mouseover or click events, for example by surrounding it by a transparent border (note that elements with a transparent background will receive mouse events, unlike elements with no background).

Categories