为列表视图项模板和列表背景色设置背景颜色时,Xamarin Forms Listview 所选项目背景颜色丢失

时间:2021-04-28 12:36:54

标签: xamarin.forms

为什么在为列表视图项模板和列表背景色设置背景色时,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>

1 个答案:

答案 0 :(得分:0)

当我停止设置 ListView 背景颜色时问题已解决。

相关问题