UXDivers / Gorilla-Player-Support

This is the public Gorilla Player support website
http://gorillaplayer.com
115 stars 17 forks source link

Error with merged Dictionaries "Cannot read property '0' of undefined" #330

Open Mr-Pearce opened 5 years ago

Mr-Pearce commented 5 years ago

Hi i have had to split my Resource Dictionary into a separate file. like this

app.xaml with some datatemplates and selectors

<?xml version="1.0" encoding="utf-8" ?>
<Application xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:customViews="clr-namespace:PigeonMobile.Views.CustomViews;assembly=PigeonMobile"
             xmlns:dataTemplate="clr-namespace:PigeonMobile.Views.Templates.DataTemplate;assembly=PigeonMobile"
             xmlns:converter="clr-namespace:PigeonMobile.ViewModels.Converter;assembly=PigeonMobile"
             x:Class="PigeonMobile.App">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="AppResources.xaml"/>
                <ResourceDictionary>
                    <DataTemplate x:Key="ComputerTemplate">
                        <x:Arguments>
                            <x:Type TypeName="dataTemplate:ComputerDataTemplate"/>
                        </x:Arguments>
                    </DataTemplate>

                    <DataTemplate x:Key="MonitorTemplate">
                        <x:Arguments>
                            <x:Type TypeName="dataTemplate:MonitorDataTemplate"/>
                        </x:Arguments>
                    </DataTemplate>

                    <DataTemplate x:Key="GenericTemplate">
                        <x:Arguments>
                            <x:Type TypeName="dataTemplate:GenericDataTemplate"/>
                        </x:Arguments>
                    </DataTemplate>

                    <DataTemplate x:Key="GenericTypeConnectionTemplate">
                        <x:Arguments>
                            <x:Type TypeName="dataTemplate:GenericTypeConnectionDataTemplate"/>
                        </x:Arguments>
                    </DataTemplate>

                    <DataTemplate x:Key="GenericTypeTemplate">
                        <x:Arguments>
                            <x:Type TypeName="dataTemplate:GenericTypeDataTemplate"/>
                        </x:Arguments>
                    </DataTemplate>

                    <customViews:DeviceTypeTemplateSelector x:Key="DeviceTypeTemplateSelector" 
                                        ComputerTemplate="{StaticResource ComputerTemplate}"
                                        MonitorTemplate="{StaticResource MonitorTemplate}"
                                        GenericTemplate="{StaticResource GenericTemplate}"
                                        GenericDeviceWithSubTypeAndConnectionTemplate="{StaticResource GenericTypeConnectionTemplate}"
                                        GenericDeviceWithSubTypeTemplate="{StaticResource GenericTypeTemplate}" >

                    </customViews:DeviceTypeTemplateSelector>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>

    </Application.Resources>
</Application>

and "AppResources.xaml" that contains my styles and converters.

Every page gets "Error occured while loading myview.xaml (error message:cannot read property '0' of undefined"

when i put the styles from the appresources.xaml back into the app.xaml (what breaks other things) it works fine again. Looks like the "MergedDictionaries" are the break point here.

attrib75 commented 5 years ago

I'm having the same issue, resolved by putting the values from the merged dictionary back into app.xaml