Xam Forms TapGestureRecognizer & TranslationX (Y or TranslateTo()) problem

JiriPelikan.6366JiriPelikan.6366 ✭✭CZMember ✭✭

Hi,

I have problem with gesture recognizers when control is moved via TranslationY (X) property or TranslateTo() method.
In Xamarin Forms 1.5 it is work properly. In Xamarin Forms 2.3 not working.

Example (partial code):

var b = new BoxView {Color = Color.Blue, BackgroundColor = Color.Blue, HeightRequest = 50};

var t = new TapGestureRecognizer();
t.Tapped += (sender, e) =>
{
System.Diagnostics.Debug.WriteLine("XXXXX TTTAP");
};
b.GestureRecognizers.Add(t);

var sl = new StackLayout
{
Orientation = StackOrientation.Vertical,
VerticalOptions = LayoutOptions.Fill,
BackgroundColor = Color.Transparent,
Children = {
new BoxView {Color = Color.White, BackgroundColor = Color.White, VerticalOptions = LayoutOptions.FillAndExpand},
b
}
};


all work properly if "b" not moved.
When I move "b" via TranslationY = -30, then tappable area still on bottom 50 points, not moved with view.

I have complex view in my app, that visible partially by default and I moving it over screen, when user needs use it.
After upgrade App from Xamarin 1.5 to 2.3, I have this problem.

Thanks for quick reply.

Jiří Pelikán.

Best Answers

Answers

  • JiriPelikan.6366JiriPelikan.6366 ✭✭ CZMember ✭✭
    edited July 2016

    To reproduce this error(?), the TranslationY or TranslateTo apply to subview of view "b".
    "clickable" area is same as if view is IsSetToBounds to true.
    Default value is false, but gesture recognizer is detect tap only on area of parent view (i move subview and gesture recognisers is attached to controls in that subview and tap detected correct, but only on area of parent view).

    And same situation is if the subview is a button without gesture recogniser attached. Only simple button produce same error.

    Clickable area is clipped to bounds of parent view, even if parent view IsClipedToBounds set to false. :-(

  • JiriPelikan.6366JiriPelikan.6366 ✭✭ CZMember ✭✭

    I tried this one more time. This problem is in xamarin 1.5 too, but not on windows phone. With Xamarin 1.5 and windows phone silverlight project all working properly. On iOS, clickable area not moved with view on boith Forms 1.5 and 2.3.

  • JiriPelikan.6366JiriPelikan.6366 ✭✭ CZMember ✭✭

    ...only one way.

    Not use complex structure of views.
    Never move a children of view. Bounds of clickable area respect bounds of the main view ("b") even if the main view has IsClippedToBounds set to false (default). You cannot tap on the button that is out of bounds of parent view, even if this button is seen.

  • MagnusWallonMagnusWallon ✭✭✭ USMember ✭✭✭

    Old thread but I just found this and thought I should share another solution if some else run in to this problem, I had a couple of clickable Frames that I moved around in a StackLayout and after I did the "TranslationTo" they just stopped working, I had other projects where it worked just fine and after a little bit analyzing I found that this was the only one where the Frames was in a StackLayout so I just changed that to a Grid like in the others and the problem was gone.
    So my conclusion is that this works just find just along as the parent is a Grid.

Sign In or Register to comment.