title: Xamarin.Forms - How can I dynamically change the height of my CarouselView?
body: <p>I have a CarouselView in which I call an object with individual and completely different Views.</p>
  <p>The only elements my ContentPage has, are the CarouselView itself, and a bottombar with a gradient above it (notice gradient in following image).</p>
  <p>I have done this in a way in which this gradient dissapears when the page's scrolling space becomes 0 (when I have scrolled to the end of the page).</p>
  <p><a href="https://i.stack.imgur.com/9L4vV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9L4vV.png" alt="" /></a></p>
  <p>The problem is that when I swipe between items in the CarouselView, the CarouselView always maintains the height of the very first View that is called in.</p>
  <p>This means that, in a View with MORE height than the 1st one, when scrolling up (after being at the very bottom, and therefore not showing a gradient) the gradient will only show again once it hits the height value of the 1st page.</p>
  <p>In a View with LESS height than the 1st one, the page will allow me to scroll down until I reach the height value of the 1st page, even if there are not enough elements on the page to even need a scroll.</p>
  <p>Essentially, what I am asking for, is if there is a way in which I can, in some way, &quot;refresh&quot; the height of the Page every time a scroll is complete to another View in the CarouselView, resolving my height issues in smaller views, and my gradient issues in larger views.</p>
  <p><strong>Main ContentPage Code Behind (Gradient)</strong></p>
  <pre><code>        public double ScrollingSpace
          {
              get
              {
                  return MainScrollView.ContentSize.Height - MainScrollView.Height;
              }
              set { }
          }
  
          // Removes gradient when scroll is complete
          private void OnScrolled(object sender, ScrolledEventArgs e)
          {
              if (ScrollingSpace &lt;= e.ScrollY) // Touched bottom
                  EndPageGradient.SetValue(IsVisibleProperty, false); // the view is GONE, not invisible
              else
                  EndPageGradient.SetValue(IsVisibleProperty, true);
          }
  
          // Removes gradient if page is not large enough to need scroll
          protected override void OnAppearing()
          {
              if (ScrollingSpace &lt;= 0)
                  EndPageGradient.SetValue(IsVisibleProperty, false); // the view is GONE, not invisible
          }
  </code></pre>
  <p><strong>Main ContentPage CarouselView XAML</strong></p>
  <pre><code>                &lt;CarouselView
                      ItemsSource=&quot;{Binding ViewList}&quot;
                      Loop=&quot;False&quot;&gt;
  
                      &lt;CarouselView.ItemTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;ContentView Content=&quot;{Binding .}&quot; /&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/CarouselView.ItemTemplate&gt;
  
                  &lt;/CarouselView&gt;
  </code></pre>
  <p><strong>Main ContentPage ViewModel (List with Views for CarouselView)</strong></p>
  <pre><code>            ViewList = new List&lt;ContentView&gt;()
              {
                  new Step1(),
                  new Step2(),
                  new Step3(),
                  new Step4(),
                  new Step5(),
                  new Step6(),
                  new Step7(),
                  new Step8()
              };
  </code></pre>
  <p>Thanks in advance!</p>