簡體   English   中英

如何在xaml / mvvm中啟用/禁用ffimageloading轉換? [Xamarin形式]

[英]How to enable/disable ffimageloading transformations in xaml/mvvm? [Xamarin forms]

我在列表視圖中有圖像,要開始將其全部灰度化。

<ffimageloading:CachedImage Source="{Binding Image}" x:Name = "Images">
       <ffimageloading:CachedImage.Transformations  >                     
            <fftransformations:GrayscaleTransformation/>
            <fftransformations:CircleTransformation/>
      </ffimageloading:CachedImage.Transformations>
 </ffimageloading:CachedImage>

<Button Command="{Binding ImageClick}" CommandParameter="{x:Reference Images}" BorderRadius="7" />

在我的mainviewmodel中,我有一個命令。

this.ImageClick = new Command(ClickedEvent);

在這里,我知道單擊了什么圖像,現在如何在該特定圖像上禁用灰度? 不禁用循環轉換。

void ClickedEvent (object sender)
{
    var clickedImage = sender as CachedImage;
    var rowData = clickedImage.BindingContext as MyClass;
    // Now i am unsure on how to proceed
}

public class MyClass
{
     public string Image {get;set;}
     public bool GrayScaleVisibility {get;set;}
}

您可以對轉換使用綁定,並根據需要更新它們。

例:

        <ffimageloading:CachedImage HorizontalOptions="Center" VerticalOptions="Center"
            LoadingPlaceholder="loading.png" ErrorPlaceholder="error.png" DownsampleToViewSize="true"
            Aspect="AspectFit" HeightRequest="400" WidthRequest="400"
            Transformations="{Binding Transformations}" Source="{Binding ImageUrl}">
        </ffimageloading:CachedImage>

還有來自文檔的ViewModel- https://github.com/luberda-molinet/FFImageLoading/blob/master/samples/ImageLoading.Forms.Sample/Shared/Pages/Transformations/TransformationsSelectorPageModel.cs

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM