OiO.lk English Android Problems with displaying images after removing them from a list in a CollectionView
Android

Problems with displaying images after removing them from a list in a CollectionView


When I delete images from the end of the list, everything is displayed correctly, but if I delete from the middle, then those images that came after the deleted image receive a white screen, how can this be fixed, example code below

        [ObservableProperty]
        ObservableCollection<ImageSource> selectedImageList = new ObservableCollection<ImageSource>();
        RemoveImageCommand = new Command<ImageSource>(RemoveImage);
        public void RemoveImage(ImageSource image)
        {
            if (SelectedImageList.Contains(image))
            {
                SelectedImageList.Remove(image);

            }
        }
      <ScrollView Orientation="Horizontal" Margin="220,0,0,0" WidthRequest="320" Grid.Column="0" >
     <StackLayout>
        <CollectionView
            ItemsSource="{Binding SelectedImageList}"
            VerticalOptions="Fill"
            HorizontalOptions="Fill"
            SelectionMode="Single"
            HorizontalScrollBarVisibility="Never">
            <CollectionView.ItemsLayout>
                <LinearItemsLayout Orientation="Horizontal"/>
            </CollectionView.ItemsLayout>
            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <Frame
                        Padding="1"
                        Margin="10,5,0,0"
                        BackgroundColor="Transparent">
                        <Grid>
                            <Image
                                Source="{Binding}"
                                Aspect="AspectFill"
                                HeightRequest="50"
                                WidthRequest="50"
                                HorizontalOptions="Center"
                                VerticalOptions="End"
                                BindingContextChanged="OnImageBindingContextChanged"
                                />
                            <ImageButton Source="cross.svg" Aspect="Fill" WidthRequest="25"                       HeightRequest="25" 
                                         Command="{Binding Source={RelativeSource AncestorType={x:Type vm:ChatWIndowViewModel}}, Path=RemoveImageCommand}" 
                                         CommandParameter="{Binding}"/>
                        </Grid>

                    </Frame>
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>
    </StackLayout>
</ScrollView>

I haven’t found anything that works yet



You need to sign in to view this answers

Exit mobile version