Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin.Forms CollectionView所选项目是否有奇怪的灰色边框?_Xamarin.forms_Datatemplate_Datatrigger - Fatal编程技术网

Xamarin.Forms CollectionView所选项目是否有奇怪的灰色边框?

Xamarin.Forms CollectionView所选项目是否有奇怪的灰色边框?,xamarin.forms,datatemplate,datatrigger,Xamarin.forms,Datatemplate,Datatrigger,我在visualstudiomac中编写代码,使用运行ios13.6的iphone8模拟器 以下是我的收藏视图的代码: <CollectionView Margin="0" VerticalScrollBarVisibility="Never" BackgroundColor="Transparent" x:Name=&q

我在visualstudiomac中编写代码,使用运行ios13.6的iphone8模拟器

以下是我的收藏视图的代码:

       <CollectionView
            Margin="0"
            VerticalScrollBarVisibility="Never"
            BackgroundColor="Transparent"
            x:Name="selectableItemsList"
            SelectionMode="Multiple"
            HorizontalOptions="Center"
            VerticalOptions="Center"
            SelectionChanged="selectableItemsList_SelectionChanged"
            ItemsSource="{Binding Services}">
            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <Image
                        Source="{Binding Image}"
                        BackgroundColor="Transparent"
                        HeightRequest="100"
                        WidthRequest="100"
                        Aspect="AspectFit"
                        HorizontalOptions="Center"
                        VerticalOptions="Start">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup
                                Name="CommonStates">
                                <VisualState
                                    Name="Normal" />
                                <VisualState
                                    Name="Focused" />
                                <VisualState
                                    Name="Selected">
                                    <VisualState.Setters>
                                        <Setter
                                            Property="BackgroundColor"
                                            Value="Yellow" />
                                    </VisualState.Setters>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Image> 
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>

以下是未选中项目时的外观:

下面是它们被选中时的样子:

看到每个图标顶部和左侧的灰线了吗?我该怎么摆脱它呢

是否有一种方法可以在选择项目时使用数据触发器更改图像的背景色

请注意:


VisualStateManager.VisualStateGroups
部分移动到
ResourceDictionary
中的样式中并不能解决问题。

尝试将图像放入网格中:

<CollectionView.ItemTemplate>
    <DataTemplate>

        <Grid Padding="10">
            <Grid.RowDefinitions>
                <RowDefinition Height="100" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100" />
            </Grid.ColumnDefinitions>

            <Image 
                Source="{Binding .}"
                BackgroundColor="Transparent"
                HeightRequest="100"
                WidthRequest="100"
                HorizontalOptions="Center"
                VerticalOptions="Start">
               
            </Image>

            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup
                        Name="CommonStates">
                    <VisualState
                            Name="Normal" />
                    <VisualState
                            Name="Focused" />
                    <VisualState
                            Name="Selected">
                        <VisualState.Setters>
                            <Setter
                                    Property="BackgroundColor"
                                    Value="Yellow" />
                        </VisualState.Setters>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>

        </Grid>
    </DataTemplate>
</CollectionView.ItemTemplate>


我还没有机会检查它,但IIRC在这里发布之前我确实尝试过。一旦我确认,我将添加评论和/或接受你的答案。当然,让我知道它是否有效:)。嗯,我在测试时没有看到这些行。你也可以试一下,没有灰色的边框。