x:Array of OnPlatform

candidodmvcandidodmv ✭✭BRMember ✭✭
edited December 2018 in Xamarin.Forms

Is it would works?

      <x:Array Type="{x:Type x:String}">
       <OnPlatform x:TypeArguments="x:String">
         <On Platform="Android, iOS">My string value for these platforms</On>
        </OnPlatform>
      </x:Array>

because I'm gettting the following error:

{System.InvalidCastException
  at (wrapper managed-to-native) System.Array.SetValueImpl(System.Array,object,int)
  at System.Array.SetValue (System.Object value, System.Int32 index) [0x00057] in <d4a23bbd2f544c30a48c44dd622ce09f>:0 
  at System.Array.System.Collections.IList.set_Item (System.Int32 index, System.Object value) [0x00000] in <d4a23bbd2f544c30a48c44dd622ce09f>:0 
  at Xamarin.Forms.Xaml.ArrayExtension.ProvideValue (System.IServiceProvider serviceProvider) [0x0003e] in D:\a\1\s\Xamarin.Forms.Xaml\MarkupExtensions\ArrayExtension.cs:30 
  at Xamarin.Forms.Xaml.ArrayExtension.Xamarin.Forms.Xaml.IMarkupExtension.ProvideValue (System.IServiceProvider serviceProvider) [0x00000] in D:\a\1\s\Xamarin.Forms.Xaml\MarkupExtensions\ArrayExtension.cs:37 
  at Xamarin.Forms.Xaml.CreateValuesVisitor.Visit (Xamarin.Forms.Xaml.ElementNode node, Xamarin.Forms.Xaml.INode parentNode) [0x00341] in D:\a\1\s\Xamarin.Forms.Xaml\CreateValuesVisitor.cs:104 
  at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x000ac] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:149 
  at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00044] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:143 
  at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00079] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:145 
  at Xamarin.Forms.Xaml.RootNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00044] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:200 
  at Xamarin.Forms.Xaml.XamlLoader.Visit (Xamarin.Forms.Xaml.RootNode rootnode, Xamarin.Forms.Xaml.HydrationContext visitorContext) [0x00054] in D:\a\1\s\Xamarin.Forms.Xaml\XamlLoader.cs:139 
  at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.String xaml) [0x00058] in D:\a\1\s\Xamarin.Forms.Xaml\XamlLoader.cs:87 
  at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[TXaml] (TXaml view, System.String xaml) 

Answers

  • ColeXColeX Xamurai Member, Xamarin Team Xamurai
    edited December 2018

    The unique usage of x:Array syntax

           <x:Array Type="{x:Type x:String}">
                <x:String>Test1</x:String>
                <x:String>Test2</x:String>
            </x:Array>
    
Sign In or Register to comment.