Android项目
public class LabelShadowEffect : PlatformEffect
{
protected override void OnAttached()
{
...
}
protected override void OnDetached()
{
...
}
}
.netstandard库
public class ShadowEffect : RoutingEffect
{
...
}
<controls:FontAwesomeLabel
...
<controls:FontAwesomeLabel.Effects>
<effects:ShadowEffect
DistanceX="2"
DistanceY="2"
Radius="2"
Color="{StaticResource HeaderTextShadowColor}" />
</controls:FontAwesomeLabel.Effects>
</controls:FontAwesomeLabel>
Element.Effects
,其定义如下
public System.Collections.Generic.IList<Xamarin.Forms.Effect> Effects { get; }
Effects="{StaticResource StandardShadowEffect}"
尝试1
system:ArraySegment
<system:ArraySegment x:Key="StandardShadowEffect" x:TypeArguments="Effect">
</system:ArraySegment>
System.ArrayTypeMismatchException:尝试将元素作为
尝试2
<generic:List x:Key="StandardShadowEffect" x:TypeArguments="Effect">
</generic:List>
类型与数组不兼容
:数组
<x:Array x:Key="StandardShadowEffect" x:TypeArguments="Effect">
</x:Array>
尝试4
<effects:ShadowEffect x:Key="StandardShadowEffect"
DistanceX="2"
DistanceY="2"
Radius="2"
Color="{StaticResource HeaderTextShadowColor}" />
奇怪的是,最后一次尝试编译而不抛出,但没有应用任何效果。