I was wondering if there is a way to change the cursor style while hovering over the Bing Maps Control in UWP/C#? I just want the cross hairs or something like it for picking positions on my Map Control. Any guidance is appreciated!
I looked at the PointerEntered() event to dynamically display the coordinates of the mouse pointer as it hovers over the Map control, but this event is never called. It must be consumed by the control and not passed up the control chain.
Related
My UWP application contains a map with several POI. I am trying to change the mouse cursor from an arrow to a hand when hovering over specific poi to indicate its clickable.
This would change the cursor as soon as it enters the map still, as a simple test, I added a PointerEntered event for the mapcontrol and within it I have the following to change the cursor:
Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Hand, 0);
It appears though the cursor does change however immediately gets overridden back to the pointer cursor.
Edit: Just realised When a poi is clicked (i.e. is selected) the cursor changes to a hand even when not over the map control until the poi is unselected. No good as I would like the cursor to change dynamically when hovering over a poi and revert back to cursor when moved away.
Change pointer cursor when hovering over map elements
I'm afraid you can't edit the default cursor for map element, Because it has handled internally, it will not fired, even you has listen PointerEntered event, it consumed by the control and not passed up the control chain. If you do want this feature, the better way is post this feature with windows feed backhub app.
I don't know if it works just like WinForms, I had to do something like this to click on labels (couldn't use link-labels), what I used was in the Mouse_Move event of the label and it was basically
if (Cursor.Current == Cursors.Default)
{
Cursor.Current = Cursors.Hand;
}
and similar changes and behaviors due to the various conditions. This however got me a small issue: this statement changes the mouse graphic anytime you move on the control, but personally on Windows settings I use the trail graphic function for the mouse (leaving a trail of pointers whenever I move the mouse on the screen), what I suggested you disables this function, or better, it conceals it, since it "recreates" the mouse graphic for every move you do onto the control, and thus it "undoes" the graphic for the mouse and recreates it as a Hand (in my instance). If it doesn't concern you though, it works just fine.
Just I repeat myself: I use this on WinForms, but since it's C# I suppose it just will work(?)
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
I am developing a touch screen application and allow users to add touch-based markup to an overlay over content using an ink canvas. I have reached a point where the view behind the overlay has an element that needs the user should be allowed to interact with, but events are captured by the InkCanvas and not by the underlying control. Is there a way to display strokes, but still allow controls behind the InkCanvas to capture events?
You can set InkCanvas.IsHitTestVisible = false and it will still display but you will not be able to interact with it and all events will go to elements lower in the z-order, which sounds like exactly what you want.
In my case I'm toggling the InkCanvas. To accomplish this, I also had to set InkCanvas.InkPresenter.InputDeviceTypes = CoreInputDeviceTypes.None to disable it.
I just wasted my entire evening on something which I thought would be very simple but it seems WPF and Google are letting me down completely.
I need a grid, 6x6 of which I fill every row and column with a custom control. I want to be able to navigate through this grid via the keyboard (I can get those events, no problem) but I cannot seem to find how I can always have the selected grid row/column in the center of my window.
I found some carousel alike implementations, but most of them only work in a single direction and I want two way navigation, yet none seem to support this nor can I extend them to do this.
I essentially want to create a PSP alike grid navigation.
One easy way is to do this:
Create a scrollable form.
Add a 6x6 grid of child controls.
In the GotFocus (or similar) event for all the controls, set the parent form scroll offset to an appropriate position to centre the child.
This is pretty straight-forward thing to implement, with a little bit of maths to work out how to centre the x,y position of a control by setting the scroll offsets (it can be tricky/confusing, but as long as you understand the coordinate systems used for scrolling, not too bad)
Or, another approach that avoids scrolling via the windows APIs and using custom controls:
Create a form
Override OnPaint to draw your grid of 6x6 "controls" as simple graphical shapes or bitmap images centred on the selected "control".
Handle keyboard (KeyDown/Up) and mouse handling (MouseDown/Up) events to make the 36 areas of the graphic respond to user inputs in the way you desire. You'll have to track the selected item and force the window to redraw its graphics to show the new state. Enable double buffering to stop it flickering.
The first approach gives you a lot of windows-based handling for free (tabbing between controls, remembering where the input focus is, and directing events to separate classes for each "control", for example). The second approach strips away all this "help" but gives you complete control over everything, which can often help avoid unintended behaviours (e.g. it won't move the input focus when the user presses Tab unless you specifically write the code to make it do that).
Given only an (x,y) point on the screen (without being allowed to use the mouse), how can you manipulate a custom UserControl?
For example, I have a custom slider that I want to manipulate using only an x, y returned by a vision code (the vision code acts like a mouse, but I am not actually supposed to use the mouse).
How does the mouse normally interact with the custom UserControl? Does the UserControl have an EventHandler when the mouse clicks/moves on it? If so, you can call the Control's Mouse_Click event (for example) from elsewhere in the code and pass in the arguments that you want. You can do this with code logic or other controls with the same parent as your UserControl.
Ideally, you can set your UserControl up so that it doesn't interact with the mouse directly. Rather, the Control and Mouse both get/set a shared variable representing the XY of the mouse. This makes things easier to test. What you want to use is Binding.