“Prefix '…' does not map to a namespace”, A designer bug?

故事扮演 提交于 2019-12-11 06:03:18

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/20332077/prefix-does-not-map-to-a-namespace-a-designer-bug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!