.NET MAUI SlideView Data Binding
The Telerik UI for .NET MAUI SlideView provides built-in options that allow you to bind data.
To define the collection of the items that will populate the control with data, use ItemsSource
(IEnumerable
).
Binding to a Complex Object
1. Add the SlideView definition in XAML:
<telerik:RadSlideView x:Name="slideView"
ItemsSource="{Binding Views}"
Orientation="Vertical">
<telerik:RadSlideView.ItemTemplate>
<DataTemplate>
<Label Text="{Binding Content}"
TextColor="#007ACC"
HorizontalTextAlignment="Center"
VerticalOptions="CenterAndExpand"/>
</DataTemplate>
</telerik:RadSlideView.ItemTemplate>
</telerik:RadSlideView>
2. Add the following namespace:
xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"
3. Add the sample Data Model and the View Model:
- Business Model
public class MyItem
{
public string Content { get; set; }
}
- View Model
public class ViewModel
{
public ObservableCollection<MyItem> Views { get; set; }
public ViewModel()
{
this.Views = new ObservableCollection<MyItem>()
{
new MyItem() { Content = "View 1" },
new MyItem() { Content = "View 2" },
new MyItem() { Content = "View 3" },
};
}
}