gpt4 book ai didi

xamarin - FFImageLoading : load into an ImageButton

转载 作者:行者123 更新时间:2023-12-02 08:07:48 25 4
gpt4 key购买 nike

在 Xamarin.Android 中,要使用 FFImageLoading 加载图像,必须使用 ImageViewAsync 而不是标准 ImageView。

如果我想将我的图像加载到 ImageButton 中,我找不到我可以使用的东西。没有找到“ImageButtonAsync”。

最佳答案

不知道这是否相关。我给了我的 svg 一个点击手势,让它像按钮一样工作。

首先在你的 xaml 中引用 FFImageLoading.Svg.Forms

namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms"

其次使用点击手势添加 svgImage

    <ffimageloadingsvg:SvgCachedImage Source="YourImageSource" >
<ffimageloadingsvg:SvgCachedImage.GestureRecognizers>
<TapGestureRecognizer NumberOfTapsRequired="1" Command="{Binding YourCommand}"/>
</ffimageloadingsvg:SvgCachedImage.GestureRecognizers>
</ffimageloadingsvg:SvgCachedImage>

您将在 ViewModel 的构造函数中调用它来初始化命令

YourCommand= new DelegateCommand(async () => await ExecuteYourCommandAsync());

创建绑定(bind)到 xaml 文件的属性

    public ICommand YourCommand
{
get => yourCommand;
set => SetProperty(ref yourCommand, value);
}

private ICommand yourCommand;

await ExecuteYourCommandAsync 是您创建的方法。并在其中放置您实际希望点击手势执行的操作的逻辑。

您还可以使用命令传递对象。让我们知道这是否有意义

关于xamarin - FFImageLoading : load into an ImageButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49819295/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com