Search code examples
c#wpfuser-controls

Why xaml keep saying "The given key "idiomas" was not present in the dictionary" when i call this user control?


i have been reading all the similar questions to this one but i couldnt find how to solve it, so please i know this have been questioned a lot, but i cant find where the problem so i need help.

First, i have a windows "MenuRecursos" (ResourcesMenu), this windows calls two types of UCs (User controls) one is just to have a nice look for buttons ->"ElementoRecursos" (ResourceElement), the other one is to show a pannel with the resources files -> "PanelMostrarArchivos" (ToShowFilesPannel).

To use both of them i have this line in the xaml xmlns:uc="clr-namespace:ElEscribaDelDJ.Resources.UserControls.Resources"

And this is how i call them

<uc:ElementoRecursos DireccionImagen="/images/icons/icons8-documents.png" 
                                 NombreElemento="{DynamicResource DocumentsTitle}" 
                                         Altura="{Binding ElementName=PrimeraColumna, Path=ActualHeight}"
                                         x:Name="UCdocuments"/>

And

<uc:PanelMostrarArchivos DataContext="{Binding}" x:Name="UCPanelMostrarArchivos"/>

But as i said, the second one gives me the "given key is not present" and i dont know why because theres no such word in any of them files neither in their .cs

now the complete xamls:

MenuRecursos

<Window x:Class="ElEscribaDelDJ.View.Resources.MenuRecursos"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:ElEscribaDelDJ.View.Resources"
        xmlns:uc="clr-namespace:ElEscribaDelDJ.Resources.UserControls.Resources"
        mc:Ignorable="d"
        Title="MenuRecursos"
        WindowStartupLocation="CenterOwner"
        WindowState="Maximized"
        Background="DarkRed"
        ContentRendered="Window_ContentRendered">

    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../Resources/View/Resources/MenuRecursos.xaml"/>
                <ResourceDictionary Source="../../Idiomas/ES/View/Resources/MenuRecursos.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>

    <Grid>
        <!-- Rejilla base, esta define las filas y columnas donde ira cada elemento del menu -->
        <Grid x:Name="GridRecursos">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <!-- 1º Elemento del menu, control de usuario personalizado -->
            
                <StackPanel x:Name="PrimeraColumna">
                <Button x:Name="BotonDetallesDocumentos" 
                    Click="BotonDetallesDocumentos_Click" 
                    Style="{DynamicResource BotonSeccion}">
                    <uc:ElementoRecursos DireccionImagen="/images/icons/icons8-documents.png" 
                                 NombreElemento="{DynamicResource DocumentsTitle}" 
                                         Altura="{Binding ElementName=PrimeraColumna, Path=ActualHeight}"
                                         x:Name="UCdocuments"/>
            </Button>
            <!-- Control de usuario que controla titulo de campaña y el botón para crear uno nuevo -->
                <Border x:Name="DescripcionDocumentos"
                        Style="{DynamicResource InformacionSeccion}">
                    <TextBlock Style="{DynamicResource Texto_InformacionSeccion}"
                               Text="{DynamicResource DocumentsInfo}"/>
                </Border>
                <ScrollViewer x:Name="ScrollViewerDocumentos" 
                              Visibility="Collapsed"
                              MaxHeight="{Binding MaximaAlturaScrollViewers}">
                    <uc:PanelMostrarArchivos DataContext="{Binding}" x:Name="UCPanelMostrarArchivos"/>
                </ScrollViewer>
            </StackPanel>
            
            <!-- 2º Elemento del menu, control personalizado de usuario -->
            <StackPanel Grid.Column="1">
                <Button x:Name="BotonDetallesReglas"
                    Click="BotonDetallesReglas_Click"
                    Style="{DynamicResource BotonSeccion}">
                    <uc:ElementoRecursos DireccionImagen="/images/icons/icons8-resume.png" 
                                         NombreElemento="{DynamicResource RulesTitle}" 
                                         Altura="{Binding ElementName=PrimeraColumna, Path=ActualHeight}" x:Name="UCresumenes"/>
                </Button>
                <Border x:Name="DescripcionResumenes"
                        Style="{DynamicResource InformacionSeccion}">
                    <TextBlock Style="{DynamicResource Texto_InformacionSeccion}"
                               Text="{DynamicResource RulesInfo}"/>
                </Border>
                <ScrollViewer x:Name="ScrollViewerReglas" 
                              Visibility="Collapsed"
                              MaxHeight="{Binding MaximaAlturaScrollViewers}">
                    <ListView>
                        <uc:Resumen_reglas/>
                    </ListView>
                </ScrollViewer>
            </StackPanel>
                
            

            <!-- 3º Elemento del menu, control personalizado de usuario -->
            <StackPanel  Grid.Row="1">
                <Button x:Name="BotonLore"
                        Click="BotonLore_Click"
                        Style="{DynamicResource BotonSeccion}">
                    <uc:ElementoRecursos DireccionImagen="/images/icons/icons8-himeji.png" 
                                         NombreElemento="{DynamicResource LoreTitle}"
                                         Altura="{Binding ElementName=PrimeraColumna, Path=ActualHeight}" x:Name="UClore"/>
                </Button>
                <Border x:Name="DescripcionLore"
                    Style="{DynamicResource InformacionSeccion}">
                    <TextBlock Style="{DynamicResource Texto_InformacionSeccion}"
                                   Text="{DynamicResource LoreInfo}"/>
                </Border>
                <ScrollViewer x:Name="ScrollViewerLore" 
                              Visibility="Collapsed"
                              MaxHeight="{Binding MaximaAlturaScrollViewers}">

                    <uc:PanelMostrarArchivos/>
                </ScrollViewer>
            </StackPanel>

            <!-- 4º Elemento del menu, control personalizado de usuario -->
            <StackPanel  Grid.Row="1" Grid.Column="1">
                <Button x:Name="BotonMedia"
                        Click="BotonMedia_Click"
                        Style="{DynamicResource BotonSeccion}">
                <uc:ElementoRecursos DireccionImagen="/images/icons/icons8-speaker.png" 
                                     NombreElemento="{DynamicResource MediaTitle}"
                                     Altura="{Binding ElementName=PrimeraColumna, Path=ActualHeight}" x:Name="UCmedia"/>
                </Button>
                <Border x:Name="DescripcionMedia" 
                        Style="{DynamicResource InformacionSeccion}">
                    <TextBlock Style="{DynamicResource Texto_InformacionSeccion}"
                                   Text="{DynamicResource MediaInfo}"/>
                </Border>
                <ScrollViewer x:Name="ScrollViewerMedia" 
                              Visibility="Collapsed"
                              MaxHeight="{Binding MaximaAlturaScrollViewers}">

                    <uc:PanelMostrarArchivos/>
                </ScrollViewer>
            </StackPanel>
            
            <!-- 5º Elemento del menu, control personalizado de usuario -->
            <StackPanel Grid.Row="2">
                <Button x:Name="BotonFichas"
                        Click="BotonFichas_Click"
                        Style="{DynamicResource BotonSeccion}">
                    <uc:ElementoRecursos DireccionImagen="/images/icons/icons8-pdf.png" 
                                     NombreElemento="{DynamicResource SheetsTitle}"
                                     Altura="{Binding ElementName=PrimeraColumna, Path=ActualHeight}" x:Name="UCfichas"/>
                </Button>
                <Border x:Name="DescripcionFichas" 
                        Style="{DynamicResource InformacionSeccion}">
                    <TextBlock Style="{DynamicResource Texto_InformacionSeccion}"
                                   Text="{DynamicResource SheetsInfo}"/>
                </Border>
                <ScrollViewer x:Name="ScrollViewerFichas" 
                              Visibility="Collapsed"
                              MaxHeight="{Binding MaximaAlturaScrollViewers}">

                    <uc:PanelMostrarArchivos/>
                </ScrollViewer>
            </StackPanel>
        </Grid>
    </Grid>
</Window>

PanelMostrarArchivos

<UserControl x:Class="ElEscribaDelDJ.Resources.UserControls.Resources.PanelMostrarArchivos"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">

    <Grid Background="White">
        <StackPanel>
            <Grid Background="White">
            <StackPanel Orientation="Horizontal" 
                        HorizontalAlignment="Center" 
                        Background="White"
                        x:Name="StackPanelCampana">
                <TextBlock Text="{Binding TituloCampana}"
                       TextDecorations="Underline" 
                       VerticalAlignment="Center"
                       FontSize="15" 
                       Margin="0,0,10,0"/>
                <Button BorderThickness="0" Background="Transparent" x:Name="BotonAnadirCampana">
                    <StackPanel>
                        <Image Source="/Images/icons/iconoMas.png" Width="15"/>
                        <TextBlock Text="{Binding TextoBoton}" FontSize="10"/>
                    </StackPanel>
                </Button>
            </StackPanel>
            </Grid>

            <WrapPanel x:Name="WrapPanelCampaign" 
                           Background="#f9f2a4">
            </WrapPanel>

            <StackPanel Orientation="Horizontal" 
                        HorizontalAlignment="Center" 
                        Background="White"
                        Visibility="Collapsed"
                        x:Name="StackPanelScenary">
                <TextBlock Text="{Binding TituloEscenario}" 
                       TextDecorations="Underline" 
                       VerticalAlignment="Center" 
                       FontSize="15" 
                       Margin="0,0,10,0"/>
                <Button BorderThickness="0" Background="Transparent" x:Name="BotonAnadirEscenario">
                    <StackPanel>
                        <Image Source="/Images/icons/iconoMas.png" Width="15"/>
                        <TextBlock Text="{Binding TextoBoton}" FontSize="10"/>
                    </StackPanel>
                </Button>
            </StackPanel>
            <WrapPanel x:Name="WrapPanelScenary" 
                           Background="#f9f2a4">
            </WrapPanel>
            
            <StackPanel Orientation="Horizontal" 
                        HorizontalAlignment="Center" 
                        Background="White" 
                        VerticalAlignment="Center"
                        Visibility="Collapsed"
                        x:Name="StackPanelAdventure">
                <TextBlock Text="{Binding TituloAventura}"
                       TextDecorations="Underline" 
                       VerticalAlignment="Center"
                       FontSize="15" 
                       Margin="0,0,10,0"/>
                <Button BorderThickness="0" Background="Transparent" x:Name="BotonAnadirAventura">
                    <StackPanel>
                        <Image Source="/Images/icons/iconoMas.png" Width="15"/>
                        <TextBlock Text="{Binding TextoBoton}" FontSize="10"/>
                    </StackPanel>
                </Button>
            </StackPanel>
            <WrapPanel x:Name="WrapPanelAdventures" 
                           Background="#f9f2a4">
            </WrapPanel>
        </StackPanel>
    </Grid>
</UserControl>

Solution

  • The error simple has gone, dont know why but now dont appears in the xaml, without doing any change