"Prefix '....' does not map to a namespace", A designer bug?

4.1k views Asked by At

My application runs and works absolutely fine. Now I want to use the VS2012 designer to design my MainWindow which is derived type of the HandledWindow from a different library.

Here is my XAML code for MainWindow:

<UI:HandledWindow x:Class="Diamond.Executor.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:UI="clr-namespace:Diamond.Core.UI;assembly=Diamond.Core"
    Title="MainWindow"
    Height="250"
    Width="500"
    Style="{DynamicResource WindowStandard}"
    WindowStartupLocation="CenterScreen"
    Loaded="Initialise">

Here is where base type HandledWindow:

namespace Diamond.Core.UI
{
    public class HandledWindow : Window
    {

What is wrong here? When I run my application anything works, the bindings, The style and it's template. But suddenly the designer says "'UI' doesn't map to a namespace". I just don't get it. It stops my development really without a reason. Perhaps a VS2012 bug, But I want to insure I am doing everything right and if there is a way to pass that bug and continue using the designer?

2

There are 2 answers

2
David von Tamar On BEST ANSWER

I've discovered what just causes the issue, But I don't know why, Because by syntax it's okay and logically it works. But XAML's desginer fails to work properly with such data binding expression:

FontSize="{Binding Path=(UI:HandledWindow.FontSizeTitle), Mode=OneWay}"

(It's part of a style inside the UI namespace that XAML declined in a whole because of this expression) Then I've changed it to this expression:

FontSize="{Binding FontSizeTitle, RelativeSource={RelativeSource TemplatedParent}}"

It does exactly the same, But now the XAML designer works again and stops ignoring the whole namespace UI because of a single data binding expression.

Anyway, The issue is finally resolved.

0
Arjan On

Just wanted to add that I experienced this same problem but in a different way: I got this exception at runtime. But only after I had added a CLR namespace to my project that referenced a namespace that was in a different project (different) assembly. After doing that, the actual error itself occurred on a binding to something in the namespace from the project itself though (the assembly that the XAML file belonged to), not the namespace from the referenced assembly. Really, really weird. This was on VS2012.

The solution to add Path= to the binding works perfectly in this case too.

I don't know if the XAML designer would also have suffered from this problem in my case because the XAML designer doesn't load anymore for this project because of an unrelated error it throws: The parameter 'frameworkName' cannot be an empty string.