Tap gesture fired for multiple sub-views inside ListView
up vote
0
down vote
favorite
I have this ListView
:
<ListView
CachingStrategy="RecycleElement"
x:Name="ItemList"
HasUnevenRows="True"
BackgroundColor="Transparent"
SeparatorColor="{x:Static local:LmcColor.defaultFg}"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
IsVisible="False"
ItemSelected="ItemList_ItemSelected"/>
Its ItemTemplate
is initialized as follows:
ItemList.ItemTemplate = new DataTemplate(() =>
new ViewCell() { View = new ItemReadView() });
And ItemReadView
is a ContentView
containing a StackView
containing an Image
called ItemImage
. I define a gesture recognizer for this Image
:
TapGestureRecognizer handler = new TapGestureRecognizer();
handler.Tapped += ((object sender, EventArgs e) =>
{
// Do stuff!
});
ItemImage.GestureRecognizers.Clear();
ItemImage.GestureRecognizers.Add(handler);
It worked fine in Xamarin Forms 2.5.1.444934. Now, in 3.3.0.967583, the "Do stuff" is being invoked for multiple image views after a single tap. I am not sure if the issue was present in Forms 3.1.0.637273. The bug only affects iOS.
As a workaround, I added a 200-msec delay before "doing stuff", and "stuff" is not "done" if a new event arrives in that interval. Luckily, the "real" event comes in last. Unluckily, the more I scroll the list view before tapping, the more events come in, and I'm afraid of some sort of resource overflow.
Has anyone noticed this? Are there any "proper" fixes? Is there anything I may be doing wrong? Should I replace TapGestureRecognizer
with something else, and if so, with what?
Thanks!
ios listview xamarin xamarin.forms uitapgesturerecognizer
add a comment |
up vote
0
down vote
favorite
I have this ListView
:
<ListView
CachingStrategy="RecycleElement"
x:Name="ItemList"
HasUnevenRows="True"
BackgroundColor="Transparent"
SeparatorColor="{x:Static local:LmcColor.defaultFg}"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
IsVisible="False"
ItemSelected="ItemList_ItemSelected"/>
Its ItemTemplate
is initialized as follows:
ItemList.ItemTemplate = new DataTemplate(() =>
new ViewCell() { View = new ItemReadView() });
And ItemReadView
is a ContentView
containing a StackView
containing an Image
called ItemImage
. I define a gesture recognizer for this Image
:
TapGestureRecognizer handler = new TapGestureRecognizer();
handler.Tapped += ((object sender, EventArgs e) =>
{
// Do stuff!
});
ItemImage.GestureRecognizers.Clear();
ItemImage.GestureRecognizers.Add(handler);
It worked fine in Xamarin Forms 2.5.1.444934. Now, in 3.3.0.967583, the "Do stuff" is being invoked for multiple image views after a single tap. I am not sure if the issue was present in Forms 3.1.0.637273. The bug only affects iOS.
As a workaround, I added a 200-msec delay before "doing stuff", and "stuff" is not "done" if a new event arrives in that interval. Luckily, the "real" event comes in last. Unluckily, the more I scroll the list view before tapping, the more events come in, and I'm afraid of some sort of resource overflow.
Has anyone noticed this? Are there any "proper" fixes? Is there anything I may be doing wrong? Should I replace TapGestureRecognizer
with something else, and if so, with what?
Thanks!
ios listview xamarin xamarin.forms uitapgesturerecognizer
Have you tried usingCommand
andCommandParameter
?
– Tom
Nov 12 at 10:06
Don't see how. Unlike, say, Button, the Image class doesn't have Command property.
– user1334767
Nov 12 at 12:20
No, it doesn't, but you can try the example in the docs.
– Tom
Nov 12 at 12:26
As this example still has TapGestureRecognizer underneath, I don't think it would make a difference. The gesture is incorrectly generated for multiple views. I don't see how this can be rectified by tying a Command to it.
– user1334767
Nov 12 at 12:36
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have this ListView
:
<ListView
CachingStrategy="RecycleElement"
x:Name="ItemList"
HasUnevenRows="True"
BackgroundColor="Transparent"
SeparatorColor="{x:Static local:LmcColor.defaultFg}"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
IsVisible="False"
ItemSelected="ItemList_ItemSelected"/>
Its ItemTemplate
is initialized as follows:
ItemList.ItemTemplate = new DataTemplate(() =>
new ViewCell() { View = new ItemReadView() });
And ItemReadView
is a ContentView
containing a StackView
containing an Image
called ItemImage
. I define a gesture recognizer for this Image
:
TapGestureRecognizer handler = new TapGestureRecognizer();
handler.Tapped += ((object sender, EventArgs e) =>
{
// Do stuff!
});
ItemImage.GestureRecognizers.Clear();
ItemImage.GestureRecognizers.Add(handler);
It worked fine in Xamarin Forms 2.5.1.444934. Now, in 3.3.0.967583, the "Do stuff" is being invoked for multiple image views after a single tap. I am not sure if the issue was present in Forms 3.1.0.637273. The bug only affects iOS.
As a workaround, I added a 200-msec delay before "doing stuff", and "stuff" is not "done" if a new event arrives in that interval. Luckily, the "real" event comes in last. Unluckily, the more I scroll the list view before tapping, the more events come in, and I'm afraid of some sort of resource overflow.
Has anyone noticed this? Are there any "proper" fixes? Is there anything I may be doing wrong? Should I replace TapGestureRecognizer
with something else, and if so, with what?
Thanks!
ios listview xamarin xamarin.forms uitapgesturerecognizer
I have this ListView
:
<ListView
CachingStrategy="RecycleElement"
x:Name="ItemList"
HasUnevenRows="True"
BackgroundColor="Transparent"
SeparatorColor="{x:Static local:LmcColor.defaultFg}"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
IsVisible="False"
ItemSelected="ItemList_ItemSelected"/>
Its ItemTemplate
is initialized as follows:
ItemList.ItemTemplate = new DataTemplate(() =>
new ViewCell() { View = new ItemReadView() });
And ItemReadView
is a ContentView
containing a StackView
containing an Image
called ItemImage
. I define a gesture recognizer for this Image
:
TapGestureRecognizer handler = new TapGestureRecognizer();
handler.Tapped += ((object sender, EventArgs e) =>
{
// Do stuff!
});
ItemImage.GestureRecognizers.Clear();
ItemImage.GestureRecognizers.Add(handler);
It worked fine in Xamarin Forms 2.5.1.444934. Now, in 3.3.0.967583, the "Do stuff" is being invoked for multiple image views after a single tap. I am not sure if the issue was present in Forms 3.1.0.637273. The bug only affects iOS.
As a workaround, I added a 200-msec delay before "doing stuff", and "stuff" is not "done" if a new event arrives in that interval. Luckily, the "real" event comes in last. Unluckily, the more I scroll the list view before tapping, the more events come in, and I'm afraid of some sort of resource overflow.
Has anyone noticed this? Are there any "proper" fixes? Is there anything I may be doing wrong? Should I replace TapGestureRecognizer
with something else, and if so, with what?
Thanks!
ios listview xamarin xamarin.forms uitapgesturerecognizer
ios listview xamarin xamarin.forms uitapgesturerecognizer
asked Nov 11 at 0:12
user1334767
124112
124112
Have you tried usingCommand
andCommandParameter
?
– Tom
Nov 12 at 10:06
Don't see how. Unlike, say, Button, the Image class doesn't have Command property.
– user1334767
Nov 12 at 12:20
No, it doesn't, but you can try the example in the docs.
– Tom
Nov 12 at 12:26
As this example still has TapGestureRecognizer underneath, I don't think it would make a difference. The gesture is incorrectly generated for multiple views. I don't see how this can be rectified by tying a Command to it.
– user1334767
Nov 12 at 12:36
add a comment |
Have you tried usingCommand
andCommandParameter
?
– Tom
Nov 12 at 10:06
Don't see how. Unlike, say, Button, the Image class doesn't have Command property.
– user1334767
Nov 12 at 12:20
No, it doesn't, but you can try the example in the docs.
– Tom
Nov 12 at 12:26
As this example still has TapGestureRecognizer underneath, I don't think it would make a difference. The gesture is incorrectly generated for multiple views. I don't see how this can be rectified by tying a Command to it.
– user1334767
Nov 12 at 12:36
Have you tried using
Command
and CommandParameter
?– Tom
Nov 12 at 10:06
Have you tried using
Command
and CommandParameter
?– Tom
Nov 12 at 10:06
Don't see how. Unlike, say, Button, the Image class doesn't have Command property.
– user1334767
Nov 12 at 12:20
Don't see how. Unlike, say, Button, the Image class doesn't have Command property.
– user1334767
Nov 12 at 12:20
No, it doesn't, but you can try the example in the docs.
– Tom
Nov 12 at 12:26
No, it doesn't, but you can try the example in the docs.
– Tom
Nov 12 at 12:26
As this example still has TapGestureRecognizer underneath, I don't think it would make a difference. The gesture is incorrectly generated for multiple views. I don't see how this can be rectified by tying a Command to it.
– user1334767
Nov 12 at 12:36
As this example still has TapGestureRecognizer underneath, I don't think it would make a difference. The gesture is incorrectly generated for multiple views. I don't see how this can be rectified by tying a Command to it.
– user1334767
Nov 12 at 12:36
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244679%2ftap-gesture-fired-for-multiple-sub-views-inside-listview%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Have you tried using
Command
andCommandParameter
?– Tom
Nov 12 at 10:06
Don't see how. Unlike, say, Button, the Image class doesn't have Command property.
– user1334767
Nov 12 at 12:20
No, it doesn't, but you can try the example in the docs.
– Tom
Nov 12 at 12:26
As this example still has TapGestureRecognizer underneath, I don't think it would make a difference. The gesture is incorrectly generated for multiple views. I don't see how this can be rectified by tying a Command to it.
– user1334767
Nov 12 at 12:36