2011-10-14 3 views
3

Eh bien, je développe une application wpf et j'ai eu une erreur étrange sur le temps de conception. Voici le code d'une forme WPF:Visual Studio 2010 - Dictionnaire Non trouvé mais il existe

<Window x:Class="ViewLayer.Frm_EnrollWaitingList" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="Frm_EnrollWaitingList" WindowStartupLocation="CenterScreen" BorderBrush="{x:Null}" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Height="390" Width="410" 
     WindowStyle="None" 
     AllowsTransparency="True" 
     ResizeMode="NoResize"> 
    <Window.Resources> 
     <ResourceDictionary Source="Dictionary/WaitingListDictorionary.xaml"/> 
    </Window.Resources> 
    <Grid> 
     <Rectangle Margin="0,0,0,0" Name="rectangle1" Stroke="{x:Null}" Fill="#FF8C90AD" Opacity="0.95" /> 
     <Button Style="{DynamicResource CommonButton}" Content="Salir" Height="80" HorizontalAlignment="Left" Margin="166,234,0,0" Name="btn_close" VerticalAlignment="Top" Width="180" /> 
    </Grid> 
</Window> 

Le problème commence ici:

<Window.Resources> 
    <ResourceDictionary Source="Dictionary/WaitingListDictorionary.xaml"/> 
</Window.Resources> 

Les ResourceDictionary sorties et dans le temps d'exécution, il fonctionne parfaitement. Mais au moment de la conception parfois lorsqu'un besoin de modifier la forme dans le concepteur de visual studio je reçois l'erreur suivante:

FileNotFoundException An error occurred while finding the resource dictionary "Dictionary/WaitingListDictorionary.xaml". 


Unable to find the specified file. 
    at Microsoft.Windows.Design.Platform.ViewProducerBase.Microsoft.Expression.DesignModel.DocumentModel.IDocumentRootResolver.GetDocumentRoot(String path) 
    at Microsoft.Expression.Platform.WPF.InstanceBuilders.ResourceDictionaryInstanceBuilder.ProvideResourceDictionary(IInstanceBuilderContext context, DocumentCompositeNode resourceDictionaryReferenceNode, IDocumentRoot& relatedRoot) 

Et je ne peux pas modifier le formulaire avec le concepteur.

Une idée? Je répète sur le temps d'exécution je n'ai aucun problème.

+0

Avez-vous ajouté le fichier xaml à votre solution? –

+0

Oui, il est ajouté –

+0

1) Votre fichier WaitingListDictionary.xaml se trouve-t-il dans un dossier Dictionary? (Si c'est le cas, essayez de déplacer le fichier dans le dossier racine du projet, le même dossier que votre fichier Window.xaml); 2) Utilisez-vous VS 2010 SP1? (Si c'est le cas, essayez unstalling SP1); – Marko

Répondre

1

La propriété Source est relative, et vous la fenêtre semble être dans le répertoire ViewLayer, de sorte que le dossier Dictionary doit également être dans le répertoire ViewLayer si vous utilisez

Source="Dictionary/WaitingListDictorionary.xaml". 

Si le dossier Dicionary est à la racine niveau, essayez

Source="/Dictionary/WaitingListDictorionary.xaml". 

Vous pouvez également utiliser un pack: // URL.

-1

Je pourrais le comprendre!

Il y avait une erreur sur le ResourceDictionary que j'essayais d'utiliser. Je l'ai réparé, et voilà! Tout fonctionne comme un charme.