【发布时间】:2015-12-06 00:57:08
【问题描述】:
我正在创建一个 ListView,它在 ViewCell 中有一些简单的项目。
当我选择其中一项时,它变为橙色。当我单击并按住(打开上下文操作)时,它变成白色...
<ListView ItemsSource="{Binding Items}" HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.ContextActions>
<MenuItem Text="Delete" />
</ViewCell.ContextActions>
<StackLayout Orientation="Horizontal" Padding="20">
<StackLayout HorizontalOptions="StartAndExpand">
<Label Text="{Binding Name}" FontSize="Large" FontAttributes="Bold" />
<Label Text="{Binding Description}" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
如何自定义这些颜色?
【问题讨论】:
-
我花了很多时间寻找自定义所选项目颜色的解决方案 - 没有成功。 SO 和 Xamarin 论坛上有一些解决方法,但没有一个让我高兴,或者他们根本不起作用。过了一会儿,我决定在触发相应的事件后立即删除选定的项目状态,并改为更改项目的文本颜色以标记选定的项目。
-
@Wosi 嘿,看看我的回答,可能对你有用:)
标签: c# android xamarin xamarin-forms