.NET MAUI SlideView Item Template
You can populate the SlideView component with various types of objects, for example, string
, int
, business objects, and so on. To customize the visualization of the views in the ItemsSource
of the control, use its ItemTemplate
property. The template can contain any of the views that you use to display the data.
Example
The following example shows how to populate the ItemsSource
with business items and customize their appearance.
1. Create a sample MyItem
class.
public class MyItem
{
public string Content { get; set; }
}
2. Add a View Model containing a collection of MyItem
objects.
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" },
};
}
}
3. Add the SlideView definition with a sample ItemTemplate
applied.
<telerik:RadSlideView x:Name="slideView"
ItemsSource="{Binding Items}">
<telerik:RadSlideView.ItemTemplate>
<DataTemplate>
<Grid RowDefinitions="Auto, *"
VerticalOptions="Center">
<Label Text="{Binding IconUnicode}"
TextColor="#3341A1"
FontFamily="TelerikFontExamples"
FontSize="64"
HorizontalOptions="Center" />
<Label Grid.Row="1"
Text="{Binding DescriptionText}"
HorizontalTextAlignment="Center"
Margin="0, 10, 0, 0" />
</Grid>
</DataTemplate>
</telerik:RadSlideView.ItemTemplate>
</telerik:RadSlideView>
4. Set the BindingContext
to the View Model:
slideView.BindingContext = new ViewModel();
Here is the result:
For a runnable example with the SlideView ItemTemplate scenario, see the SDKBrowser Demo Application and go to SlideView > Templates.