Search code examples
wpfxamlvisual-studio-2012namespacesdesigner

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


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?


Solution

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