Hi,
I'm having an issue with TableView vs. ListView. When you tap a row in a ListView, the standard behaviour is to highlight that row until another is selected. In Xamarin.Forms, this works as expected when using a ListView, but not with a TableView. With a TableView, the row is selected for a moment, but appears to be immediately deselected and the "selected" background colour fades away.
To test, I created 2 basic Forms apps and ran the Android app in each case. Here's the code:
TableView:
namespace BasicFormsApp
{
public class MyItem
{
public string ItemName { get; set; }
}
public class App : Application
{
private readonly List<MyItem> _itemList = new List<MyItem>
{
new MyItem {ItemName = "Item 1"},
new MyItem {ItemName = "Item 2"}
};
public App()
{
var tableSection = new TableSection();
var tableRoot = new TableRoot();
var myTable = new TableView(tableRoot);
foreach (var item in _itemList)
{
var tableCell = new ViewCell
{
View = new Label
{
Text = item.ItemName
}
};
tableSection.Add(tableCell);
}
tableRoot.Add(tableSection);
myTable.Root = tableRoot;
MainPage = new ContentPage
{
Content = myTable
};
}
}
}
ListView:
namespace BasicFormsApp
{
public class MyItem
{
public string ItemName { get; set; }
}
public class App : Application
{
private readonly List<MyItem> _itemList = new List<MyItem>
{
new MyItem {ItemName = "Item 1"},
new MyItem {ItemName = "Item 2"}
};
public App()
{
MainPage = new ContentPage
{
Content = new ListView
{
ItemsSource = _itemList
}
};
}
}
}
Am I doing something wrong, or is this an issue with TableView rendering in Xamarin.Forms?
Thanks,
Peter.