微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

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

为什么在为列表视图项模板和列表背景色设置背景色时,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" 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 背景颜色时问题已解决。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。