title: How to use UIPageControl in Xamarin C# for iOS
body: <p>I have worked on titanium in past and it was very simple to use the paging control there. Just begun Xamarin iOS development and got stuck with this paging control. Not sure how to use it. I found an example <a href="http://www.gooorack.com/2013/07/31/xamarin-uipagecontrol-and-uiscrollview-for-ios-homescreen-look/" rel="nofollow noreferrer">here</a>. It worked fine. <strong>My question is ,is the UIPageControl Useless ? I read it <a href="https://stackoverflow.com/questions/1103915/is-uipagecontrol-useless-by-itself">here</a> that it is so.</strong> <strong>Does Xamarin have any control which could work like Titanium's Scrollable View ?</strong>  Please suggest any better method than the code below . </p>
  
  <p>Here's the code </p>
  
  <pre><code> public override void ViewDidLoad ()
      {
          base.ViewDidLoad ();
  
  
          // Perform any additional setup after loading the view, typically from a nib.
          createAndAddViewsToPagerControl ();
      }
  
      void createAndAddViewsToPagerControl ()
      {
          try {
              int pageCount = PagerControlMain.Pages;
              Console.WriteLine ("Pages Count in Page Control" + pageCount);
  
  
              List&lt;UIColor&gt; _colList = new List&lt;UIColor&gt; {
                  UIColor.Red,
                  UIColor.Green,
                  UIColor.Blue,
                  UIColor.Yellow
              };
  
              int i = 0;
              for (i = 0; i &lt; pageCount; i++) {
                  UILabel label = new UILabel ();
                  RectangleF rectangle = new RectangleF ();
                  rectangle.X = (this.PagerScrollView.Frame.Width * i) + 50;
                  rectangle.Y = 0;
                  rectangle.Size = this.PagerScrollView.Frame.Size;
                  label.Frame = rectangle;
                  label.Text = i.ToString ();
                  label.TextColor = _colList [i];
  
                  this.PagerScrollView.AddSubview (label);
              }
  
              this.PagerControlMain.Pages = pageCount;
              PagerScrollView.BackgroundColor = UIColor.Gray;
              PagerScrollView.ContentSize = new SizeF (PagerScrollView.Frame.Width * i, PagerScrollView.Frame.Height);
              this.PagerScrollView.Scrolled += ScrolledEvent;
  
  
          } catch (Exception ex) {
              Console.WriteLine ("Exception in PagerControl : " + ex);
          }
      }
  
      private void ScrolledEvent (object sender, EventArgs e)
      {
          this.PagerControlMain.CurrentPage = 
              (int)System.Math.Floor (this.PagerScrollView.ContentOffset.X
          / this.PagerScrollView.Frame.Size.Width);
  
          Console.WriteLine ("Scroll Event Fired");
      }
  
      partial void PagerControlMain_ValueChanged (UIPageControl sender)
      {
          Console.WriteLine ("Current Page " + sender.CurrentPage);
          //throw new NotImplementedException ();
      }
  </code></pre>