如何在后面的 C# 代码中使用 Xamarin Community Toolkit 扩展属性和属性?

How to use Xamarin Community Toolkit extension properties and attributes in the C# code behind?

我正在使用 Xamarin.Community 工具包的 ShadowEffect.ColorIconTintColorEffect.TintColor 到 XAML,它工作正常,但怎么能我通过 C# 代码隐藏实现了这一点。我在 Google 和社区论坛上进行了搜索,但找不到任何内容。

这是我在 XAML 中的代码:

<BoxView BackgroundColor="White" xct:ShadowEffect.Color="Black" />
<Image Source="{extensions:ImageResource MyProject.Images.sample.png" xct:IconTintColorEffect.TintColor="Blue" />

在 XAML 中一切正常,但我想从后面的 C# 代码中实现。

ShadowEffect.SetColor(boxView, Color.Black);

IconTintColorEffect.SetTintColor(image, Color.Blue);

其中 boxViewimage 是您的 xaml 使用 x:Name 或在代码中实例化的实例。