Hi,
RadListPicker - missed selected index property
Thanks,
<telerikInput:RadListPicker x:Name="timeTypeListPicker" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" HeightRequest="35" WidthRequest="100"
ItemsSource="{Binding TimeTypesItem}"
DisplayMemberPath="Value"
SelectedItem="{Binding SelectedTimeTypesItem, Mode=TwoWay}" >
</telerikInput:RadListPicker>
Works for me:
Using the following code.
MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="GeneralFeatures.MainPage" xmlns:telerikInput="clr-namespace:Telerik.XamarinForms.Input;assembly=Telerik.Maui.Controls.Compatibility" BackgroundColor="{DynamicResource SecondaryColor}"> <Grid> <telerikInput:RadListPicker x:Name="timeTypeListPicker" VerticalOptions="Start" ItemsSource="{Binding Items}" DisplayMemberPath="FullName" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" /> <Label Text="{Binding StatusText}" VerticalOptions="End" HorizontalOptions="Center" Margin="10"/> </Grid> </ContentPage>
MainPage.xaml.cs
using System.Collections.ObjectModel; using Telerik.XamarinForms.Common; namespace GeneralFeatures; public partial class MainPage : ContentPage { public MainPage() { InitializeComponent(); BindingContext = new PeopleViewModel(); } } public class PeopleViewModel : NotifyPropertyChangedBase { public Person selectedItem; private string statusText; public PeopleViewModel() { Items = new ObservableCollection<Person>() { new Person("Freda","Curtis"), new Person("Jeffery","Francis"), new Person("Ema","Lawson"), new Person("Niki","Samaniego"), new Person("Jenny","Santos"), new Person("Eric","Wheeler"), new Person("Emmett","Fuller"), new Person("Brian","Johnas"), }; SelectedItem = Items[3]; } public ObservableCollection<Person> Items { get; set; } public Person SelectedItem { get => selectedItem; set { if (UpdateValue(ref selectedItem, value)) { var selectedIndex = Items.IndexOf(selectedItem); StatusText = $"Selected Index: {selectedIndex}"; } } } public string StatusText { get => statusText; set => UpdateValue(ref statusText, value); } } public class Person { public Person(string name, string lastName) { Name = name; LastName = lastName; } public string Name { get; set; } public string LastName { get; set; } public string FullName => $"{Name} {LastName}"; }
Moving Forward
Here are some ideas you can ponder while investigating your custom business logic and application lifecycle: