Search code examples
wpfxamlprefix

How can i make a prefix so i can address a folder in xaml


I always have problems making new prefixes in xaml. Most of the time, i get the message that the URI cannot be found in the assembly. My setup:

I have a WPF project (in a solution with class libs and asp.NET projects) with a MainWindow.xaml file. The XAML starts with : Window x:Class="MainWindow" ... . So as default, there's no namespace given to it. In that same project i made a folder "Folder". In that folder, i have resx-files. What i need to do is make a prefix in xaml so i can address those files. I was thinking of :

xmlns:p="clr-namespace:WpfApplication.Folder"

and then for my controls

<Label Content="{x:Static p:NameResxFile.KeyName></Label>

However, the prefix generates the "URI cannot be found in the assembly" error. I'm i just failing at making prefixes?

Thanks in advance.

EDIT

If you cannot make a namespace ref to a folder, what is happening here?


Solution

  • xmlns specifies namespaces, it does not bother with folders or files, if you need access to an external resource you can load it into your control's resources via ResourceDictionary.

    There was something like this i think:

    <Window.Resources>
        <ResourceDictionary x:Key="ExternalRes" Source="Folder/File.xaml"/>
        ....
    </Window.Resources>