Listview selected row and command

NessaNessa ✭✭DEMember ✭✭

heeeeei
does anyone know how i know which row is being tapped/selected in listview?
and how can i do a command for listview?
both didnt really work for me
Thx

Answers

  • N_BauaN_Baua ✭✭✭✭✭ INMember ✭✭✭✭✭

    Hi @Nessa,

    I assume Your listview is bound to Observable Collection (of a specific type)

    <ListView ItemSelected="OnSelectedItem" /> (in non MVVM enviornment you get the selected item via this event)

    Or in MVVM way

    When your Model class is

    public class MyClassItem{
    public string MyClassItemProperty{get; set;}
    public string MyClassItemAnotherProperty{get; set;}
    }

    and MyClassItemList is list or Observable Collection of MyClassItem

    <ListView
    ItemsSource="{Binding MyClassItemList}"
    SelectedItem="{Binding MyClassItem, Mode=TwoWay}" >
    <ListView.ItemTemplate>
    <DataTemplate>
    <TextCell Text="{Binding MyClassItemProperty}" Detail="{Binding MyClassItemAnotherProperty}"/>
    </DataTemplate>
    </ListView.ItemTemplate>
    </ListView>

    Hope this helps,

    Regards,
    N Baua

Sign In or Register to comment.