Forum Xamarin.Forms

Scrollview stops scrolling after LayoutTo

Hi there. The problem I'm facing is that I've a RelativeLayout composed by 4 StackLayouts, they're all side by side. Only two of them are shown at the same time. The two that are hidden have a scrollview, and when the user slides them to the front page they should be able to scroll, but they dont!

I can get them to work if when the app starts they're in the front page. If they are outside they won't work.

Sometimes I get this error:
unexpected nil window in _UIApplicationHandleEventFromQueueEvent, _windowServerHitTestWindow: <UIWindow: 0x7d882600; frame = (0 0; 1024 768); gestureRecognizers = <NSArray: 0x7d882b10>; layer = <UIWindowLayer: 0x7d8821c0>>

Any hints?

Thanks in advance!

Posts

  • xceedxceed GBMember ✭✭

    Can we see some code please? :)

  • Here it is!

    This is how I lay them side by side:

        layout.Children.Add(usernetworkV,
                        Constraint.RelativeToParent ((parent) => parent.Width),
                        null,
                        Constraint.RelativeToParent ((parent) => parent.Width / 3),
                        Constraint.RelativeToParent ((parent) => parent.Height-Device.OnPlatform(80,60,60))
                    );
    
                    layout.Children.Add(timelineV,
                        null,
                        null,
                        Constraint.RelativeToParent ((parent) => parent.Width / 3),
                        Constraint.RelativeToParent ((parent) => parent.Height)
                    );
    
                    layout.Children.Add(utenteV,
                        Constraint.RelativeToParent ((parent) => parent.Width / 3),
                        null,
                        Constraint.RelativeToParent ((parent) => parent.Width *2/3),
                        Constraint.RelativeToParent ((parent) => parent.Height)
                    );
    
                    layout.Children.Add(sidebarV,
                        Constraint.RelativeToParent ((parent) => -parent.Width / 4),
                        null,
                        Constraint.RelativeToParent ((parent) => parent.Width / 4),
                        Constraint.RelativeToParent ((parent) => parent.Height)
                    );
    

    And this is how I toggle the side menus:

    public void toggle(){
                Rectangle oldBounds = (Parent as RelativeLayout).Bounds;
                oldBounds.X = -oldBounds.Width/ 3 * (_toggled?0:1);
                (Parent as RelativeLayout).LayoutTo (oldBounds, 600, (_toggled ? Easing.CubicOut : Easing.SpringOut));
    
                _toggled = !_toggled;
            }
    

    Thanks ;)

  • I managed to create a simple app that illustrates my problem, here is the github repo:
    https://github.com/fcouceiro/xamarin-forms-scroll-view-troubleshoot

    Have a look guys! I don't think is a Xamarin Forms bug, I think I must call some invalidate function somewhere so that the view layout its content again.. Don't know! ;)

    Thanks for your help

  • I've started an SO question on this: link

  • PauloEduardoPauloEduardo USMember

    Good afternoon,

    I know the topic is old but I have the same problem, does anyone know the solution?

Sign In or Register to comment.