Declare a DictionaryEntry in XAML

Hello,

I am attempting to build a Dictionary in XAML but I'm having a few issues.
I have tried to use ArrayList and adding DictionaryEntry but the when this value is retrieved the dictionary Entry give an error
<collections:ArrayList x:Key="GroupConversions" >
<collections:DictionaryEntry Key="bla" Value ="bla"/>
</collections:ArrayList>

I have also tried a HashTable but I cannot even add values to this in XAML as it doesn't contain a ContentPropertyAttribute.
<collections:HashTable x:Key="GroupConversions" >
<collections:DictionaryEntry Key="bla" Value ="bla"/>
</collections:ArrayList>

I know this is easy enough to create in the ViewModel or the code behind, but I would like to do this in XAML only.

Thanks for the help
Joe

Tagged:

Answers

  • ColeXColeX Member, Xamarin Team Xamurai

    It's not a good idea to declare a data type in XAML , it goes against the MVVM design .

    AFAIK, we can only access with ResourceDictionary.

    For example :

    <ContentPage.Resources>
        <ResourceDictionary>
            <x:String x:Key="a">abc</x:String>
            <x:String x:Key="b">abc</x:String>
            <x:String x:Key="c">abc</x:String>
            <x:String x:Key="d">abc</x:String>
        </ResourceDictionary>
    </ContentPage.Resources>
    
Sign In or Register to comment.