The context for this question is handling translations. I've set up a ResourceDictionary which contains other ResourceDictionary instances with the relevant localized strings for different areas, in order to group them more easily. Different translation item XAML files will be stored within different language code folders, however they're not necessary for the example below.

TranslationItems1.xaml

<ResourceDictionary ...>
    <ResourceDictionary x:Key="Group1">
        <sys:String x:Key="Field1">Group1Field1</sys:String>
        <sys:String x:Key="Field2">Group1Field2</sys:String>
        <sys:String x:Key="Field3">Group1Field3 out</sys:String>
    </ResourceDictionary>
    <ResourceDictionary x:Key="Group2">
        <sys:String x:Key="Field1">Group2Field1</sys:String>
        <sys:String x:Key="Field2">Group2Field2</sys:String>
        <sys:String x:Key="Field3">Group2Field3 out</sys:String>
    </ResourceDictionary>
</ResourceDictionary>

For parts where I want to use these translations, I set the DataContext and bind accordingly.

UserControl1.xaml

<UserControl ...>
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary x:Key="Strings">
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="TranslationItems1.xaml" />
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </ResourceDictionary>
    </UserControl.Resources>
    <Button>
        <Button.ContextMenu>
            <ContextMenu DataContext="{DynamicResource Strings}">
                <MenuItem Header="{Binding Path=[Group1][Field1]}" />
                <MenuItem Header="{Binding Path=[Group1][Field2]}" />
                <MenuItem Header="{Binding Path=[Group1][Field3]}" />
            </ContextMenu>
        </Button.ContextMenu>
    </Button>
    <Button>
        <Button.ContextMenu>
            <ContextMenu DataContext="{DynamicResource Strings}">
                <MenuItem Header="{Binding Path=[Group2][Field1]}" />
                <MenuItem Header="{Binding Path=[Group2][Field2]}" />
                <MenuItem Header="{Binding Path=[Group2][Field3]}" />
            </ContextMenu>
        </Button.ContextMenu>
    </Button>
</UserControl>

This approach appears to work perfectly. It builds and runs and my strings appear as expected.

IntelliSense however complains with error code XLS0521, and states Type 'DictionaryEntry' is not a collection. for the binding paths. This error disappears on build but will reappear if I make any subsequent changes to the file.

Googling that error code gives me a whopping 10 results. I'm assuming this error occurring is because it doesn't know that Group1 and Group2 are dictionaries, but I don't know how to explicitly state that they are via XAML.

How can I specify in XAML that Group1 and Group2 are dictionaries?

0 Answers