Adding scroll control to the CarouselView
Add a new file into the Controls
folder called CarouselScroll.cs
and implement the first part as follows:
public class CarouselScroll : ScrollView { #region Private Properties private CarouselLayout _carouselLayout; #endregion public DataTemplate ItemTemplate { set { _carouselLayout.ItemTemplate = value; } } public CarouselScroll() { Orientation = ScrollOrientation.Horizontal; _carouselLayout = new CarouselLayout(); Content = _carouselLayout; } }
The CarouselScroll
will inherit the ScrollView
object as this will be the bounding view for the CarouselLayout
. We are also going to create a DataTemplate
variable for setting the DataTemplate
object inside the CarouselLayout
. Then, in the constructor, we instantiate a new CarouselLayout
object as the Content
of the ScrollView
.
Now let's add a custom binding object for the ItemsSource
. Like a ListView
, we will bind...