开发者

Visual Studio 2010 - Dictionary Not found but it exists

Well, I´m developing a wpf application and I got a strange error on design time. This is the code of a wpf form:

<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>

The problem starts here:

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

The ResourceDictionary exits and in execution time it works perfectly. But at design time sometime when a want to modify the form in visual studio designer i get the following error:

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)

And I can not edit the form with the designer.

Any idea? I repeat on execution time I have no problems.


The Source property is relative, and you window appears to be in the ViewLayer directory, so the Dictionary folder must also be in the ViewLayer directory if you use

Source="Dictionary/WaitingListDictorionary.xaml".  

If the Dicionary folder is at the root level, try

Source="/Dictionary/WaitingListDictorionary.xaml".

You can also use a pack:// URL.


I could figure it out!

There was an error on the ResourceDictionary I was trying to use. I fixed it, and voila! Everything works like a charm.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜