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
129112
129112
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
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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