Get the Selected item value

<DataTemplate x:Key="SendingPDFTemplate">
<StackLayout BindableLayout="{Binding Files}">
<Grid>
<Image Source="{Binding Image}" />
<Label Text="{Binding Name}" />
</Grid>
</StackLayout>
</DataTemplate>

<DataTemplates:MessageDataTemplateSelector
x:Key="MessageDataTemplateSelector"
SendingPDFMessageTemplate="{StaticResource SendingPDFTemplate}"
SendingPictureMessageTemplate="{StaticResource SendingPictureTemplate}" />

<list:SfListView
x:Name="messageListView"
Margin="0,5"
AutoFitMode="Height"
ItemTemplate="{StaticResource MessageDataTemplateSelector}"
ItemsSource="{Binding Messages}"
Orientation="Vertical"
SelectedItem="{Binding SelectedMessage, Mode=TwoWay}"
SelectionBackgroundColor="Transparent"
VerticalOptions="FillAndExpand">
</list:SfListView>

Classes:

public class Messages{
public int Id {get;set;}
public List<File> Files { get; set; }
}

public class File{
private ImageSource _image;
public string Name { get; set; }
public byte[] Content { get; set; }
public ImageSource Image
{
get { return _image; }
set { RaiseAndUpdate(ref _image, value); }
}
}

Hi,

For this listView inside the stacklayout bindablelayout, how to tap and get the files name.

Tna


1 Reply

SY Suthi Yuvaraj Syncfusion Team September 14, 2022 12:29 PM UTC

Hi MuthuKumar,


We would like to let you know that SfListView allows you to get the selected items on the SelectionChangedEvent, when the selection process is completed. ItemSelectionChangedEventArgs contains AddItems ,where you can get the data of selected items. Please refer the below user guide link for more reference.


UG Link: Selection in Xamarin ListView control | Syncfusion


Also we have attached the selection related documentation for your reference

Selection in Xamarin ListView control | Syncfusion

How to notify item selection using MVVM in Xamarin.Forms ListView? | Syncfusion KB


Please let us know if you need further assistance.


Regards,

Suthi Yuvaraj.


Loader.
Up arrow icon