SurfaceListBox not responding to touch gestures for several seconds - c#

I have a WPF-program that has a grid with two columns. First one has buttons and second one has WindowsFormsHost-element that embeds an ActiveX component. One button hides the WindowsFormsHost-element and shows a SurfaceListBox on the same location on screen in the second column. If I have touched the WindowsFormsHost element just before pressing this button, it takes approximately 8 seconds from the last touch until the SurfaceListBox becomes responsible for touch gestures.
The thread is probably not blocked, because I can use the buttons in another column, and use use the ListBox with mouse.
The ListBox remains unresponsive for touch events forever, if I touch it within the 8 second waiting time. So it seems that somehow the ListBox does not get the touch events.
If I programmatically create another ListBox, it does not work either, for 8 seconds, if it is placed in same are on screen than the WindowsFormsHost was.
I noticed there is a method CaptureTouch() for UIElement, but I cannot get hold of to the TouchDevice that I could pass it as parameter. I have set ManipulationEnabled="true" for every UIElement and no TouchEvent will be fired.
I have also desperately used UpdateLayout() etc with no luck.
So I think the touch gestures are somehow routed wrong and after the waiting time it implicitly fixes the routing, but is there a way I could make the touch gestures work in the ListBox immediately?

The problem disappeared when I removed "focus tracking for launching on-screen keyboard" from my program.
So in case of somebody else struggles with the same problem,
http://www.infragistics.com/community/blogs/blagunas/archive/2013/12/17/showing-the-windows-8-touch-keyboard-in-wpf.aspx and SurfaceListBoxes aren't meant for each other.

Related

Trigger screen reader when control already has focus

I'm looking for a way to force a winforms controls which already has focus to be (re)announced by the screen reader.
The situation is that I have a manually painted area which the user is able to navigate around using the arrow keys, but since it's only a single control the focus is always the same so the screen reader only announces the control on the initial focus.
I have tried Focus()ing (and Select()ing) on a second control then immediately Focus()ing back, but this doesn't trigger the screen reader. The only way I've managed to get that working is to get the second control to wait 100ms then refocus back from a background thread, but then the second control is announced to the user, and there's a minefield of edge cases and race conditions.
It looks like UIA LiveRegions is the solution for this for .NET 4.7+, but I'm stuck on 4.6.
Any ideas how I can force the screen reader to re-announce the control under focus?

UWP - Onscreen keyboard closes when switching to another textbox

I'm experiencing a strange bug(?) with my uwp app.
I have a page with multiple textboxes for user input that each have the InputScope set to number, which then opens the keyboard in tablet mode as expected. However if you tap on the next box the keyboard closes and a second tap is needed to open the keyboard. This also happens if the user hits tab to switch boxes.
I presume this has something to do with the Focus() event firing before the previous textbox has fired the loss of focus event but im unsure how to override the behavior.
How can i prevent the onscreen keyboard from closing, but also make sure the correct inputscope is still maintained?
Edit: Upon further investigation, the issue seems to be almost random. Sometimes you can move to different boxes and it remains open but other times it closes the keyboard every time.
This issue has been resolved with some others, in Windows 10 version 1803 released on 30th April, 2018.
You can try to play with InputPane that is a container for on-screen keyboard. For example, doing a small delay once the pane is trying to hide, then detect attempts to show the pane again (and cancel pending hide).
myPane = InputPane.GetForCurrentView();
myPane.Showing += myShowingHandler();
myPane.Hiding += myHidingHandler();
At least, you can receive a size of underlying screen region on the pane showing so you can put a placeholder (margin or dummy grid) on your UI to prevent it jumping up and down on keyboard show/hide.
I tried your case on my WP but I cannot reproduce your experience:
When I tap to other TextBox, keyboard stays opened and I can continue typing.
Keyboard hides as expected when I tap somewhere to whitespace.
Don't you have keyboard connected to your device?

Detect when interial scrolling begins WinRT XAML

Someone I've been banging my head around - is there a way to detect when intertial scrolling begins on a scrollviewer in WinRT's XAML model in a touch input scerario, no matter how round abouts it is?
I've tried listening to PointerUp & Down's & Released & Move events on UI elements and on the CoreWindow object itself and none of them fire after the scrollviewer starts moving (so it seems the scrollviewer is eating the pointer moved events before the application Window even recieves them? What fun DirectInput is...)? And of course overlaying something on top the of scrollviewer that catches events and then says it hasn't handled them simply doesn't work (I'm guessing a side effect of DirectInput again). So is there a way to do, without writing my own panel?
(I've been tasked to write a flipview like control where the items scale / zoom up as they become the active item - and it looks horrible to only fire it on the selection changed event).

How can I determinate invoke of keyboard in Windows Phone

I have a textBox, how can I make the keyBoard appear in 500 milliseconds. Is it possible?
No, at least not directly. If you work around it, your users won't be expecting that behaviour and it may lead to trouble.
WARNING - Here be dragons!
I guess you could spoof it if you really wanted to do it (which I wouldn't recommend). You could exactly position a transparent rectangle over the control, and on tap of that control, start a timer that hides the rectangle and sets focus on the textbox, but that's a road to nightmares as you try to position the control, and re-enable it on blur.

Animate a e.Graphics.DrawLine with arrowhead

I need to "animate" an arrow. It can go in any direction (up, down, left, right and diagonals) and the arrowhead will be at the end. It needs to appear as if it is growing from orgin to the end.
To make matters more complicated it has to be in a user control so it is possible to add to the controls collection in the forms and remove it to delete it from the screen, and its background is really transparent (no color.transparent) so i can't paint the background to "clear" the previous line.
I have it static already (drawn from origin to end) but i can't animate it. I tried to add a timer in the user control but I fail to get a correct algorithm to calculate the intermediate ends of the line while it is growing.
Any help would be appreciated.
Thanks
When using animation on a Windows form you have to use another thread. Look into using a background worker: http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx
You don't need another thread - I have succesfully implemented Windows Forms animation.
My design:
Use a Windows.System.Forms.Timer object to call a callback function 'Animate()' at regular intervals
the Animate() function updates a property of your arrow, and then calls Invalidate() on the windows control
this all happens in the same UI thread, so yuo will not get any flicker effects (as long as your control has double duffering switched on).

Categories

Resources