If you use templates in Visual Studio 2013 for Xamarin applications, the version of Xamarin.Forms is a bit outdated and does not support scrolling. To fix this, just nuget 'update-package' and this code
public class MainPage : ContentPage { public MainPage() { Label label = new Label { Text = "This is a very long label which I expect to scroll horizontally because it in a ScrollView.", Font = Font.SystemFontOfSize(24), }; this.Content = new ScrollView { Content = label, Orientation = ScrollOrientation.Horizontal, }; } }
The code works great on Android.
For iOS, the code will work properly.
Unfortunately, for the date, for WP8 there is an error and the hack is to add a custom renderer.
using System.Windows.Controls; using App2.WinPhone; using Xamarin.Forms; using Xamarin.Forms.Platform.WinPhone; [assembly: ExportRenderer(typeof(ScrollView), typeof(FixedSVRenderer))] namespace App2.WinPhone { public sealed class FixedSVRenderer : ScrollViewRenderer { protected override void OnModelSet() { base.OnModelSet(); if (Model.Orientation == ScrollOrientation.Horizontal) { // Enable horiz-scrolling Control.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; } } } }
Stefan turcanu
source share