0
我已經爲我的ListView
創建DataTemplate
,但不顯示ListViewItems
的文本。如何綁定ItemsSource
的文本?添加到您的StackLayout前在沒有XAML的情況下在ListView DataTemplate中將ItemsSource綁定到標籤
List<string> stringList;
ListView myListView = new ListView
{
ItemsSource = stringList,
ItemTemplate = new DataTemplate(() =>
{
StackLayout sl = new StackLayout
{
VerticalOptions = LayoutOptions.FillAndExpand,
Orientation = StackOrientation.Horizontal,
};
sl.Children.Add(new Label
{
FontSize = 14,
});
return new ViewCell { View = sl };
})
但我如果我需要我的ItemSource綁定字符串列表使用什麼第二個參數? – InfernumDeus
已更新@InfernumDeus – Zroq