当我试图插入带有BoxView的GradientBackground时,会引发此异常。在c#代码中,我插入了国旗,但这还不够。我怎么能解决呢?
System.TypeLoadException:“无法从typeref (程序集”Xamarin.Forms.Core、Version=2.0.0.0、Culture=neutral、PublicKeyToken=null中的预期类'Xamarin.Forms.GradientStop‘)解析类型
XAML代码
<BoxView>
<BoxView.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<GradientStop Color="Gray" Offset="0" />
<GradientStop Color="Transparent" Offset="1.0" />
</LinearGradientBrush>
</BoxView.Background>
</BoxView>c#代码
public MainPage()
{
InitializeComponent();
Device.SetFlags(new[] { "Brush_Experimental" });
}发布于 2020-12-28 18:32:13
首先,您应该分别在App类或AppDelegate/MainActivity中设置标志。
(关于旗帜的正式文档以及如何选择)
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/internals/experimental-flags
尝试在包管理器中更新您的Xamarin.Forms NuGet包,以前的版本常常会导致类似的问题。
也尝试清洁和重建你的解决方案。我创建了一个关于如何选择Xamarin实验特性的视频,如果其他所有功能都失败了,尝试观看它,并捕捉您的项目和我的示例项目之间的区别:https://www.youtube.com/watch?v=W008ZlCjEZ8
https://stackoverflow.com/questions/65481752
复制相似问题