我一直在尝试在Xamarin.Forms上创建自定义控件。
我的解决方案可以在UWP上很好地构建,但是对于android,我总是会遇到相同的错误:
不可能计算表达式“ [System.Version] :: Parse('')”。字符串太长或太短。
如何解决这个问题?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using App2;
using App2.UWP;
using Xamarin.Forms.Platform.UWP;
using Windows.UI.Xaml.Controls;
[assembly: ExportRenderer(typeof(NavigationPannel), typeof(NavigationPannelRenderer))]
namespace App2.UWP
{
class NavigationPannelRenderer : ViewRenderer<NavigationPannel, NavigationView>
{
protected override void OnElementChanged(ElementChangedEventArgs<NavigationPannel> args)
{
base.OnElementChanged(args);
if (Control == null)
{
NavigationView nav_view = new NavigationView();
nav_view.MenuItems.Add(new NavigationViewItem
{
Content = "My content",
Icon = new SymbolIcon(Symbol.Folder),
Tag = "content"
});
SetNativeControl(nav_view);
}
}
}
}
编辑: 我提出了另一个解决方案,并尝试逐步重做所有事情,起初我的android项目编译得很好,但是当我添加UWP自定义渲染器并在Windows上编译后,它开始显示相同的错误
答案 0 :(得分:0)
好的,所以我再次一步一步地进行了逐行复制/粘贴,这一次没有错误发生。
我真的不知道这里发生了什么,所以如果有人有任何想法,我仍然很乐意接受。