MAUI 版本中传递 ImageSource 时出现问题

问题描述 投票:0回答:1

调试时,一切都正确传输,并且删除图像的方法工作正常,但在release版本中我遇到了ImageSource未传输的问题,这可能与什么有关?

<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" InputTransparent="True"
                            />
                        <Image Source="cross.svg" Aspect="Fill" WidthRequest="17" HeightRequest="17" HorizontalOptions="End" Margin="2" VerticalOptions="Start"/>
                    </Grid>
                    <Frame.GestureRecognizers>
                        <TapGestureRecognizer  Command="{Binding Source={RelativeSource AncestorType={x:Type vm:ChatWIndowViewModel}}, Path=RemoveImageCommand}" CommandParameter="{Binding }"/>
                    </Frame.GestureRecognizers>
                </Frame>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>
</StackLayout>
public void RemoveImage(ImageSource image)
{
    SelectedImageList.Remove(image);
    if (SelectedImageList.Count == 0)
    {
        if (!EditMode)
        {
            IsImageSelected = false;
            IsVisible = false;
        }
        else
        {
            EditImage = false;
        }
    }
}

我尝试以不同的方式调用命令,通过按钮和点击按钮进行调用,但没有任何帮助

image command maui release imagesource
1个回答
0
投票

假设

SelectedImageList
是一个ImageSource列表,则为CollectionView的DataTemplate指定x:Datatype如下

 <DataTemplate x:DataType="ImageSource">
© www.soinside.com 2019 - 2024. All rights reserved.