Marquee for Xamarin.Froms(IOS) RRS feed

  • Question

  • User192977 posted

    I have a StackLayout(View) inside of which I am having Image and Label aligned Horizontally (refer screenshot below). The Label should have a Marquee property. For that, we are using animation on the Label (using TranslateTo) and giving new X-position on tap gesture, when we click on the label the label starts moving right to left as Marquee, but it is overlapping the image. Is there any way to implement it in Xamarin.Forms IOS? so Marquee Label won't overlap the Image.

    Wednesday, April 5, 2017 5:45 AM

All replies

  • User207279 posted

    Simple option is to change StackLayout to Absolute or RelativeLayout which will make Layout on Z-axis which should atleast fix the Label overlap on image issue. If changing that is not possible then you should try with the RaiseChild() in from Layout. try the below sample code and let us know whether this works.


      <StackLayout Orientation="Vertical">
        <Label Text="Xamarin Forms CardView Demo"
                 HorizontalOptions="CenterAndExpand" />
        <ListView x:Name="listView"
                  ItemsSource="{Binding CardDataCollection}" >
                <StackLayout Orientation="Horizontal" x:Name="Layout" >
                  <Image x:Name="Image" Margin="5" Source="icon"/>
                  <StackLayout Orientation="Horizontal">
                  <Label x:Name="label"
                         Text="Hello this is forms">
                      <TapGestureRecognizer Command="{Binding ClickToSendCommand}" CommandParameter="{x:Reference Layout }"/>
    public class CardDataViewModel
            public IList<CardDataModel> CardDataCollection { get; set; }
            public CardDataViewModel()
                CardDataCollection = new List<CardDataModel>();
            private async void ClickCommandAction(Forms.View person)
                var layout = person as StackLayout;
                var image = layout.FindByName<Image>("Image");
                var textLabel = layout.FindByName<Label>("label");
                await textLabel.TranslateTo(-300, 0, 1000);
            private void GenerateCardModel()
                for (var i = 0; i < 10; i++)
                    var cardData = new CardDataModel()
                        Title = "CardRow-No" + i,
                        Owner = "Card-No" + i,
                        AlertColor = i % 2 == 0 ? Color.Green : Color.Blue,
                        ClickToSendCommand = new Command<Forms.View>(ClickCommandAction)
        public class CardDataModel
            public string Title { get; set; }
            public string Owner { get; set; }
            public Color AlertColor { get; set; }
            public ICommand ClickToSendCommand { get; set; }
    Wednesday, April 5, 2017 9:02 AM
  • User192977 posted

    Hi Dinesh,

    we tried raise child but it didn't work for us. for Marquee use for loop in label only it worked as Marquee .

    On click of Label Gesture:

    var marqueeLabelText = clickedRes.MarqueLabel; for (int i = 0; i < clickedRes.MarqueLabel.Length; i++) {

                       clickedRes.MarqueLabel= clickedRes.MarqueLabelSubstring(i, clickedMarqueeRes.ResourceMarque.Length - i);
                       await Task.Delay(300);
    Wednesday, April 5, 2017 12:38 PM
  • User192977 posted

    Thanks for Suggestion.... :)

    Wednesday, April 5, 2017 12:38 PM
  • User357442 posted
    1. Create a custom class:

      public class MarqueeLabel : Label {}
    2. Use this custom class in your Xamarin Forms Layout.

    3. Add the Nuget package MarqueeLabel.iOS to your Xamarin.iOS project (Xamarin bindings for the MarqueeLabel).

    4. Create a custom label renderer in your Xamarin.iOS project:

      [assembly: ExportRenderer(typeof(Test.Forms.App.UI.Views.MarqueeLabel), typeof(TestMarqueeLabelRenderer))]
      namespace Test.Forms.App.iOS.Renderer
          public class TestMarqueeLabelRenderer : LabelRenderer
              protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
                  var x = new MarqueeLabel.iOS.MarqueeLabel();
    Tuesday, August 6, 2019 8:52 AM
  • User322157 posted

    @LucaZiegler there is no Nuget available for android .... can you tell me how to do this for android.

    Tuesday, January 28, 2020 6:51 AM