Forum Xamarin.Forms

ScrollView not scroll in Windows Phone

RaffynaRaffyna ITMember

Hi,
I developed a multiplatform application with a scroll view.
The ScrollView scroll in Android and iOS but it doesn't work in Windows phone,
Could you help me?

This is my code:

StackLayout sLay = new StackLayout
{
Orientation = StackOrientation.Horizontal
};

var scrollView = new ScrollView {
Content = sLay,
Orientation = ScrollOrientation.Horizontal
};
...
var layout = new RelativeLayout();

layout.Children.Add(scrollView,
Constraint.Constant(10),
Constraint.Constant(80),

             Constraint.RelativeToParent((parent) =>
            {
                return parent.Width - 10;
            }),
           Constraint.RelativeToParent((parent) =>
            {
                return (.2 * parent.Height);
            }));

Content = layout;

Thanks in advance!

Posts

  • VolodymyrSavchenkoVolodymyrSavchenko UAMember ✭✭✭
    edited June 2016

    I guess that page Content should looks like this.Content = ScrollView.
    You want only half of page scrolling?

    Post entire code, please, so i could run it.

  • RaffynaRaffyna ITMember

    Yep, I want the scroll only in a partial page.

  • VolodymyrSavchenkoVolodymyrSavchenko UAMember ✭✭✭

    @Raffyna said:
    Yep, I want the scroll only in a partial page.

    Post entire code of your page so i'll try to help you.
    Have you tried to set height property to scrollview?

  • RaffynaRaffyna ITMember

    This is the code:
    SharedVaraibles.Instance._mood = 0;

            StackLayout parentScroll = new StackLayout();
    
            StackLayout sLay = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
            };
    
            var scrollView = new ScrollView
            {
                Content = sLay,
                Orientation = ScrollOrientation.Horizontal,
    
            };
    
            var tapGesture = new TapGestureRecognizer();
            tapGesture.Tapped += onTapEmoji;
    
            image = new Image[Constant.imgName.Length];
            //riempio la scroll view con i bottoni
            for (var i = 0; i < Constant.imgName.Length; i++)
            {
                image[i] = new Image
                {
                    Source = Constant.imgNameGray[i],
    
                };
    
                //listener del click button
                image[i].GestureRecognizers.Add(tapGesture);
                sLay.Children.Add(image[i]);
    
            }
    
            feedback = new Editor
            {
                BackgroundColor = Color.White,
                TextColor = Color.Black
            };
    
            var feedBackLabel = new Label
            {
                Text = Constant.FeedbackLabel,
                TextColor = Color.White,
                FontSize = 20
            };
    
            var titleLabel = new Label
            {
                Text = Constant.Domanda,
                TextColor = Color.White,
                FontSize = 28,
                FontAttributes = FontAttributes.Italic,
                HorizontalOptions = LayoutOptions.Center,
                };
    
            var tapGestureBtn = new TapGestureRecognizer();
            tapGestureBtn.Tapped += OnTapSendButton;
    
            var btnSend = new Image
            {
                Source = "SendButtonSmall.png"
            };
            btnSend.GestureRecognizers.Add(tapGestureBtn);
    
            var layout = new RelativeLayout();
            layout.BackgroundColor = Color.Teal;
    
            layout.Children.Add(titleLabel,
                 Constraint.Constant(40),
                  Constraint.Constant(40),
    
                  Constraint.RelativeToParent((parent) =>
                  {
                      return parent.Width - 20;
                  }),
                Constraint.RelativeToParent((parent) =>
                {
                    return (.1 * parent.Height);
                }));
    
    
            layout.Children.Add(scrollView,
                  Constraint.Constant(10),
                  Constraint.Constant(80),
    
                  Constraint.RelativeToParent((parent) =>
                 {
                     return parent.Width - 10;
                 }),
                Constraint.RelativeToParent((parent) =>
                 {
                     return (.2 * parent.Height);
                 }));
    
            layout.Children.Add(feedBackLabel,
                  Constraint.Constant(20),
                  Constraint.Constant(240),
    
                  Constraint.RelativeToParent((parent) =>
                  {
                      return parent.Width;
                  }),
                Constraint.RelativeToParent((parent) =>
                {
                    return (.1 * parent.Height);
                }));
    
            layout.Children.Add(feedback,
                  Constraint.Constant(20),
                  Constraint.Constant(280),
    
                  Constraint.RelativeToParent((parent) =>
                  {
                      return parent.Width - 46;
                  }),
                Constraint.RelativeToParent((parent) =>
                {
                    return (.4 * parent.Height);
                }));
    
    
            layout.Children.Add(btnSend,
                 Constraint.RelativeToParent((parent) =>
                 {
                     return (parent.Width * .5) - 20;
                 }),
                   Constraint.RelativeToParent((parent) =>
                   {
                       return .85 * parent.Height;
                   })
    
          );
    
            Content = layout;
    
  • seanydaseanyda GBMember ✭✭✭✭✭

    Try a different version of Xamarin, sometimes scrollview doesn't work in all versions i've found :S

  • RaffynaRaffyna ITMember

    I've the last version of xamarin O.o

  • seanydaseanyda GBMember ✭✭✭✭✭

    Downgrade :)

  • RaffynaRaffyna ITMember

    It didn't work :(

Sign In or Register to comment.