title: How to get selected elements index of a gridview?
body: <p>Here, I am creating a dynamic gridview.</p>
  
  <pre class="lang-cs prettyprint-override"><code>    private void PopulateImages()
              {
                  ObservableCollection&lt;Attachment&gt; Images = new ObservableCollection&lt;Attachment&gt;();
                  Images.Add(new Attachment { Name = "Image 1", Index = 0 });
                  Images.Add(new Attachment { Name = "Image 2", Index = 1 });
                  Images.Add(new Attachment { Name = "Image 3", Index = 2 });
                  Images.Add(new Attachment { Name = "Image 4", Index = 3 });
                  Images.Add(new Attachment { Name = "Image 5", Index = 4 });
                  Images.Add(new Attachment { Name = "Image 6", Index = 5 });
  
                  gridLayout.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) });
                  gridLayout.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) });
  
                  gridLayout.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(33, GridUnitType.Star) });
                  gridLayout.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(33, GridUnitType.Star) });
                  gridLayout.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(33, GridUnitType.Star) });
  
                  gridLayout.ColumnSpacing = 8;
                  gridLayout.RowSpacing = 8;
  
                  var productIndex = 0;
                  for (int rowIndex = 0; rowIndex &lt; 2; rowIndex++)
                  {
                      for (int columnIndex = 0; columnIndex &lt; 3; columnIndex++)
                      {
                          if (productIndex &gt;= Images.Count)
                          {
                              break;
                          }
                          var product = Images[productIndex];
                          productIndex += 1;
  
                          var frame = new Frame
                          {
                              HeightRequest = 95,
                              WidthRequest = 70,
                              CornerRadius = 10,
                              HasShadow = false,
                              BorderColor = Color.FromHex("#CCCCCC")
                          };
  
                          var image = new Image
                          {
                              Source = "addImage.png",
                              VerticalOptions = LayoutOptions.Center,
                              HorizontalOptions = LayoutOptions.Center,
                              HeightRequest = 35,
                              WidthRequest = 35
                          };
  
                          frame.Content = image;
  
                          TapGestureRecognizer tapped = new TapGestureRecognizer();
  
                          tapped.Tapped += (s, e) =&gt;
                          {                        
                              TakePhoto();
                          };
  
                          frame.GestureRecognizers.Add(tapped);
  
                          gridLayout.Children.Add(frame, columnIndex, rowIndex);
                      }
                  }
              }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/rHkT6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rHkT6.png" alt="result"></a></p>
  
  <p>When user clicks on any frame, it will open the camera and after capturing, the  image will be set to the selected frame.</p>
  
  <p>So how to get the selected frame index of this grid?
  Also how to find the image source from this image view?</p>
  
  <p>Is any plugin available to use this type of features for multiple image upload in xamarin forms?</p>