xaml - Xamarin 形成 UWP - Listview 在加载 viewcells 时显示黑色背景
问题描述
在使用数据加载 Listview 时,黑色背景显示为加载每个视图单元格。有谁知道改变颜色或删除那种风格?
我也尝试从代码隐藏加载 Listview。有没有办法自定义这个?
黑色背景发生在视图单元加载之前。
<ContentPage.Content>
<StackLayout>
<Button Pressed="Button_Pressed" Text="Back"/>
<ListView x:Name="MyList" BackgroundColor="LightBlue" HasUnevenRows="False">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid HeightRequest="60" BackgroundColor="Bisque">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Text="{Binding Name}"/>
<Label Grid.Column="1" Text="{Binding Quantity}"/>
<Label Grid.Column="2" Text="{Binding Value}"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>
代码隐藏:
public ObservableCollection<ListItemModel> listItems { get; }
public ListViewPage2 ()
{
listItems = new ObservableCollection<ListItemModel>();
listItems.Add(new ListItemModel { Name = "First", Quantity = 1, Value = "10.00" });
listItems.Add(new ListItemModel { Name = "Secound", Quantity = 2, Value = "20.00" });
listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
InitializeComponent();
MyList.ItemsSource = listItems;
}
private void Button_Pressed(object sender, System.EventArgs e)
{
Application.Current.MainPage.Navigation.PopModalAsync();
}
解决方案
推荐阅读
- machine-learning - 馈送神经网络:IndexError:索引超出范围
- python - 使用 matplotlib 将数据添加到绘图
- c++ - __STDCPP_DEFAULT_NEW_ALIGNMENT__ 出现之前的年龄是多少
- typescript - TypeScript 断言函数
- kubectl - 由于不支持的版本“extensions/v1beta1”,使用 kubectl 部署 Ditto 和 MongoDB 失败
- python - 如何从两个字典创建嵌套字典?
- ios - 如何检查设备中是否安装了 TikTok?
- c++ - 将 CDC 对象分配给 CPaintDC 类型时出现错误 C2248。[MFC]
- python - [多处理python]:没有输出
- mysql - 升级过程中从 5.6 到 5.7 的 AWS RDS MySQL 复制