【发布时间】:2021-04-28 12:36:54
【问题描述】:
为什么在设置列表视图项模板的背景颜色和列表背景颜色时,Xamarin Forms Listview 选定项背景颜色会丢失?
XAML
<ListView x:Name="CorrecpondencesListView"
ItemsSource="{Binding Correspondences}"
HasUnevenRows="True" CachingStrategy="RecycleElement"
ItemSelected="OnSelectSingleCorrecpondences"
SeparatorColor="{StaticResource lightGrey}"
IsPullToRefreshEnabled="True"
SelectionMode="Single"
BackgroundColor="{DynamicResource DynamicBackgroundColor}"
Refreshing="ListView_Refreshing">
<ListView.ItemTemplate>
<DataTemplate>
<controls:CustomViewCell SelectedItemBackgroundColor="#F3F3F3" >
<ViewCell.View>
<Grid Padding="10,10,10,10" RowSpacing="2" BackgroundColor="{DynamicResource DashboardItemsDarkSurface}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
</Grid>
</ViewCell.View>
</controls:CustomViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
【问题讨论】:
-
添加您的代码,以便我们确定您做错了什么。
-
感谢您的回复,我一直在为 ListView 及其项目模板设置背景颜色。
标签: xamarin.forms