2017-04-13 40 views
1

我爲Windows Phone 8.1(RT)的Xamarin表單創建了應用程序。我將XF更新爲最新版本2.3.4.231。我在運行應用:Windows Phone 8.1(RT)的Xamarin表單 - xaml例外

-windows電話8.1設備

-windows電話8.1模擬器

-Mobile模擬器10.0.14393(86)

它的工作就可以了。 但是,當我運行應用程序到Windows 10設備(手臂)時,我有很多例外。我嘗試不同的啓動頁面,並獲得鬃毛異常(從XAML):

-Cannot assign property \"ColumnDefinitions\": Property does not exists, or is not assignable, or mismatching type between value and property" 

-StaticResource not found for key ... 

-An item with the same key has already been added 

所有這些錯誤都與XAML。 我不使用XamlCompilationOptions.Compile。

最後工作版本XF我的應用程序2.3.2.127

這個小例子: 我改變開始頁面。我有例外:

-StaticResource not found for key StandardPadding 

這是我的網頁的一部分:

<StackLayout Padding="{StaticResource StandardPadding}"> 

我在資源的App.xaml:

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

你能分享你的XAML代碼嗎? – mindOfAi

+0

我在我的問題中增加了一個小例子 – FetFrumos

+0

ColumnDefinitions是Grid的一部分(基本上是Grid.ColumnDefinitions) - 您需要爲整個頁面提供XAML以便我們查看它的錯誤 - 不只是一小段代碼片段。 –

回答

0

我解決了這個問題。錯誤出現在我的xaml代碼中。 Xamarin Forms 2.3不支持xaml中的Windows OnPlatform。所以我用這個擴展:

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; 
    } 
} 

我在我的xaml代碼中使用了這個類。但是在XF 2.3.4 Device.OS中已經過時了。我從我的xaml代碼中刪除了XOnPlatform。我在xaml代碼中使用OnPlatform。這是工作。賓果:)

相關問題