1

Thanks for your help. Let me assure you I have searched high and low for this issue.

I'm currently using Xamarin Forms to create a mobile application. I have a List View that is generated from a table in a database. This all works fine.

My List view populates fine with the text of each field, I want the user to select the TextCell in the list view and this is put into a variable / string.

At the moment every time i try to use ListExample.SelectedItem.ToString() I get the value of my Database Model class path. See images. I can see that the values are inside the text. I just cannot access them. Any help would be great.

<ListView x:Name="SearchResults" 
          ItemsSource="{Binding Post}" 
          ItemSelected="SearchResults_ItemSelected" 
          SelectedItem="{Binding OBJUNIQUEID, Mode=TwoWay}">
    <ListView.ItemTemplate>
        <DataTemplate>
            <TextCell x:Name="selected" 
                      Height="15" 
                      TextColor="Black" 
                      Text="{Binding OBJUNIQUEID}"/>
        </DataTemplate>
    </ListView.ItemTemplate>

</ListView>

The c# code as is follows.

var results = conn.Query<Post>("SELECT * FROM OBJ_MASTER").ToList();

SearchResults.ItemsSource = results
CredoConsole.Text = "Item Selected: " + SearchResults.SelectedItem.ToString(); 

Image: Mobile App interface Bottom red text is wrong as you can see

If anyone has anything that can point me in the right direction.

1 Answer 1

2
protected void SearchResults_ItemSelected(object sender, SelectedItemChangedEventArgs e) {

  var item = (Post)e.SelectedItem;
  var id = item.OBJUNIQUEID;
}
Sign up to request clarification or add additional context in comments.

1 Comment

Hi, Thanks guys really appreciate taking the time out to help me with this. Tested out as soon as i got into work and it's working!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.