Windows Phone 8.1(RT)中的Xamarin表单-xaml例外

Windows Phone 8.1(RT)中的Xamarin表单-xaml例外,xaml,windows-phone-8.1,xamarin.forms,win-universal-app,Xaml,Windows Phone 8.1,Xamarin.forms,Win Universal App,我使用Xamarin表单为Windows Phone 8.1(RT)创建了应用程序。我将XF更新为最新版本2.3.4.231。我的应用程序正在运行到: -windows phone 8.1设备 -windows phone 8.1仿真器 -移动仿真器10.0.14393(x86) 它工作正常。 但当我在Windows10设备(arm)上运行应用程序时,我有很多例外。我尝试了不同的起始页并获得了许多异常(来自xaml): 所有这些错误都与xaml有关。 我不使用XamlCompilationOpt

我使用Xamarin表单为Windows Phone 8.1(RT)创建了应用程序。我将XF更新为最新版本2.3.4.231。我的应用程序正在运行到:

-windows phone 8.1设备

-windows phone 8.1仿真器

-移动仿真器10.0.14393(x86)

它工作正常。 但当我在Windows10设备(arm)上运行应用程序时,我有很多例外。我尝试了不同的起始页并获得了许多异常(来自xaml):

所有这些错误都与xaml有关。 我不使用XamlCompilationOptions.Compile

我的应用程序2.3.2.127的最后工作版本XF

这个小例子: 我更改了起始页。我有例外:

-StaticResource not found for key StandardPadding
这是我的页面的一部分:

 <StackLayout  Padding="{StaticResource StandardPadding}">

App.xaml中的我的资源:

 <Application.Resources>
    <ResourceDictionary>
      <Thickness x:Key="StandardPadding">16</Thickness>
    </ResourceDictionary>
</Application.Resources>

16

我解决了这个问题。错误在我的xaml代码中。xaml中的Windows OnPlatform不支持Xamarin Forms 2.3。所以我使用了这个扩展:

public class XOnPlatform<T> : OnPlatform<T>
{
    public T Windows { get; set; }

    public static implicit operator T(XOnPlatform<T> onPlatform)
    {
        if (Device.OS == TargetPlatform.Windows)
        {
            return onPlatform.Windows;
        }

        return (OnPlatform<T>)onPlatform;
    }
}
公共类平台:OnPlatform
{
公共T窗口{get;set;}
公共静态隐式运算符T(XOnPlatform on Platform)
{
if(Device.OS==TargetPlatform.Windows)
{
返回平台.Windows;
}
返回(平台上)平台上;
}
}

我在xaml代码中使用了这个类。但在XF 2.3.4中,Device.OS已经过时。我从xaml代码中删除了XOnPlatform。我在xaml代码中使用了OnPlatform。这是我的工作。答对了:)

我解决了这个问题。错误在我的xaml代码中。xaml中的Windows OnPlatform不支持Xamarin Forms 2.3。所以我使用了这个扩展:

public class XOnPlatform<T> : OnPlatform<T>
{
    public T Windows { get; set; }

    public static implicit operator T(XOnPlatform<T> onPlatform)
    {
        if (Device.OS == TargetPlatform.Windows)
        {
            return onPlatform.Windows;
        }

        return (OnPlatform<T>)onPlatform;
    }
}
公共类平台:OnPlatform
{
公共T窗口{get;set;}
公共静态隐式运算符T(XOnPlatform on Platform)
{
if(Device.OS==TargetPlatform.Windows)
{
返回平台.Windows;
}
返回(平台上)平台上;
}
}

我在xaml代码中使用了这个类。但在XF 2.3.4中,Device.OS已经过时。我从xaml代码中删除了XOnPlatform。我在xaml代码中使用了OnPlatform。这是我的工作。答对了:)

你能分享你的XAML代码吗?我在问题中添加了一个小例子ColumnDefinitions是Grid的一部分(基本上是Grid.ColumnDefinitions)——你需要为你的整个页面提供XAML,以便我们看到它有什么问题——不仅仅是一个小片段。这不是我的XAML的问题。这是我的项目和Xamarin表单(2.3.4.231)的问题。我的代码在模拟器(8.1和10)中工作,在Windows 10设备(arm)中不工作。当我降级到XF 2.3.2.127时,我的代码在Windows 10设备中工作。可能是您忘记调用
InitializeComponent()
在你的app.xaml.cs中?你能分享你的xaml代码吗?我在我的问题中添加了一个小例子ColumnDefinitions是网格的一部分(基本上是Grid.ColumnDefinitions)-你需要为整个页面提供xaml,以便我们看到它有什么问题-不仅仅是一个小片段。我的xaml没有问题。这是我的项目和Xamarin表单(2.3.4.231)的问题。我的代码在模拟器(8.1和10)中工作,在Windows 10设备(arm)中不工作。当我降级到XF 2.3.2.127时,我的代码在Windows 10设备中工作。可能是您忘记调用
InitializeComponent()在你的app.xaml.cs中?