GestureListener select bad item when scroll moves - windows-phone-7

I saw here and in some articles that I should use GestureListener to get Tap from user then use SelectionChanged. I tried it and I like it. But I have problem with it. When my listbox moves (scrolls) and I try tap I get bad item (I get item from last tap). When I scroll and wait for stopping scroll and then tap everything is fine (I get exactly item which I tap on). Anyone else with this problem? Any solution? Thanks

As (according to your tags) you're targetting 7.1, there is no need to have to use a GestureListener to detect Tap events.
All UIElements in Silverlight 4 (which 7.1 is based on) support a built in Tap event. See http://msdn.microsoft.com/en-us/library/system.windows.uielement.tap(v=vs.95).aspx
Using a GestureListener has an unnecessary performance overhead and can cause other issues as you're discovering.
You should use a Tap event in the individual ListBoxItems or the SelectionChanged event on the ListBox not both.
If you create a new Databound Application, the code in the default project files will show an example of how to use SelectionChanged and in that instance trigger a page navigation.
In future, you may also get a better, faster answer by showing the code you are having problems with, not just describing it.

Related

Fling right in Xamarin Forms

is there an easyish way in Xamarin Forms to implement a "Swipe Right" event on an item, preferably a row in a grid.
I'm thinking about the way that you delete messages in the GMail app, which also nicely shows the row starting to move before you finish the swipe, so that you can tell that something is about to happen.
If this is in the category of things that is difficult enough that it is better to find a different solution then that would still be useful to know.
Thanks
Cedd
Refer https://github.com/pateljay0323/XamarinFormsGestures
for different gestures like SingleTap, DoubleTap, LongPress, Swipe, Pinch, Move, Up, Down, Unknown

Ignore events from children of a ScrollViewer while scrolling

Alright here is my issue. I have a Pivot view. Inside that pivot view a scroll viewer containing many stack panels and grids. On some of the grids I have MouseButton Up Events. What is happening is if I flick the scroll it scrolls as expected but when I release my finger most of the time it fires off the event from mousebutton up. Because technically I let up. The problem is these grids completely fill the screen so finding an area without a mousebutton up to scroll is near impossible. What I want to happen is if the user flicked to scroll I would ideally like it to ignore the mousebutton up event. It does this successfully sometimes but pretty rarely and I have noticed I have to flick pretty fast for it to work as expected.
Any ideas on how to prevent this activity. I assume there is as Listboxes work perfect.
i think u should use windows phone toolkit GestureListener to recognize flick event
I ended up setting a bool for when the scrollviewer was scrolling and based on that allowing the mouseup action to run my code. Here is the the site I used to implement the bool based on scrolling status.
http://blogs.msdn.com/b/ptorr/archive/2010/07/23/how-to-detect-when-a-list-is-scrolling-or-not.aspx

Is it possible to remove and move a row of listbox on itself?

Just like the UITableView on iphone.
users can remove or move a row on UITableView.
There is only one button to switch the UITableView to editing mode.
but for listbox on wp7 , I need 3 buttons, one for removing the selected row, one for moving the row up, one for moving the row down.
Welcome any comment
The Windows Phone ListBox doesn't support these features out of the box, but it would be possible to add them yourself using a DataTemplate.
Here's a blog post about creating a custom DataTemplate for your ListItems.
At a high level, you'll need to create a template that contains:
Enter edit mode button
Delete button
Sort up/down buttons
Then in your code, you'll need to toggle the visibility of the delete and sort buttons, as well as handle user clicks on each of the buttons. Doable, but a fair amount of work.
In my opinion, a better option would be to use a approach that's different from what you might be used to but is more familiar to Windows Phone users: the ContextMenu. This control allows you to pop up a menu when the user performs a long touch (tap-and-hold) on an item.
Here's a good tutorial about incorporating this control into your app.
Take a look at re-order ListBox here. It shows how to retemplate the ListBox.
For removing on item, you just need to remove its data source item. See how to use ObservableCollection.
If you want to show effect when an item is removed, use Event Triggers for the Unloaded event.

Slider stops working after first use

I have a Slider control inside a ScrollView (there are other elements, but those are the pertinent ones). When you "let go" of the slider (OnMouseLeftButtonUp - also works for taps), a network command is sent and the slider is momentarily greyed out. After the slider becomes available again, when I try to drag it, it will not work, and the "let go" event doesn't fire.
I have already tried setting e.Handled to True/False but it seems to do nothing. What would cause a Slider to stop working after it's used one time? -Or- Is there a better event I should be using to detect when the value changes on the slider after the user has let go of it?
Found the problem. You can't use a Toggle Switch (from the Silverlight SDK) with a slider because one takes exclusive control of a GestureListener.
Here's the fix I used, it worked perfectly (near the bottom):
http://social.msdn.microsoft.com/Forums/en-US/wpdevelop/thread/ba8bfef3-44a2-4e63-bded-97013e38772e/
You just have to wrap your sliders in a <Canvas> element and insert some event handlers.

Silverlight 2.0 RC Drag and drop ordering of a ListBox

I am trying to give a ListBox drag and drop ordering functionality and I have hit a wall. I got it to work when I specify the list box items in xaml but it does not work when I bind to a list it no longer works because the items are no longer of a listboxitem type.
I found this code http://blog.dobaginski.com/josh/?p=52 that allows me to get the underlying ListBoxItem but I can't get the mouse move event to fire.
I have went through other tutorials but have not been able to find one that deals with a ListBox. Has anyone done this with a ListBox.
The events I am using are SelectedChange, MouseMove, and LeftMouseButtonUp (I think that name is right). I am not using LeftMouseButtonDown because I couldn't get it to fire.
As far as i know you cannot get at the listbox item container when using data binding. YOu could in Beta 1.
You also cannot set a mouse event handler in the style, you must use a data template, just so you know.
You will likely have to use the mouse move event from a parent element, probably the UserControl or main layout control that hosts the listbox.
State changes and animations need to be in the style though so... you still cant get at the listbox item, just the element inside it in the data template.
Oh and if doing drag and drop HitTest is now protected so that will make the Drop harder.
since today you can download the final 2.0 version of Silverlight with some add ons, check the Scott's web log
I've been trying to do the same thing in WPF,
but have only found many buggy implementations.
One person has guided me towards the blog of Beatriz Costa,
and from what I remember she's one of those rare geniouses,
so I suggest you read that as well... I know I will
Blog of Beatriz Costa

Resources