Forum Xamarin.Forms

Read TextCell Binding from ListView

How can i read text in listview


<ListView.ItemTemplate>



</ListView.ItemTemplate>

Output :

I've tried it, use i ListMK_ItemSelected

private void ListMK_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
string item = e.SelectedItem.ToString();
DisplayAlert("ItemSelected", item, "Ok");
}

When selected output :

i wanna output like this :

ItemSelected
BAHASA INDONESIA 1
PB0I1103

Help, Thanks Before...

Answers

  • JohnHJohnH GBMember ✭✭✭✭✭
    edited September 2019
    SelectedItem is the model of the row you selected. So cast as the model, then you can access the properties.
  • JarvanJarvan Member, Xamarin Team Xamurai

    Get the model by the selectedItem in itemSelected event, then display the NAMA_MK info in popup.

    private void Listview_ItemSelected(object sender, SelectedItemChangedEventArgs e)
    {
        var model = e.SelectedItem as ListViewModel;
    
        DisplayAlert("ItemSelected", model.NAMA_MK, "Ok");
    }
    
  • JarvanJarvan Member, Xamarin Team Xamurai
    edited September 2019

    @ridwandwiseptian
    Have you solved the problem? If you are facing some issues while implementing, try to post the particular error with the corresponding codes here.

Sign In or Register to comment.