【问题标题】:Xamarin Forms Listview selected item background color is lost when setting the background color for the list view item template and list bg color设置列表视图项模板的背景颜色和列表背景颜色时,Xamarin Forms Listview 选定项背景颜色丢失
【发布时间】: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


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-15
    • 1970-01-01
    相关资源
    最近更新 更多