在WPF XAML文件中的另一个项目引用名字空间 [英] Reference name space in another project in WPF xaml file

查看:1704
本文介绍了在WPF XAML文件中的另一个项目引用名字空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我引用到另一个项目(类库,所有的车型所在)的命名空间。

I am referencing to a namespace of another project(class library, where all the models resides).

在相关问题中提到,他们已经sloved的probem通过将装配以及到的.xaml文件。但是,这并没有为我工作。这就是为什么我张贴。

as mentioned in the related questions, they have sloved the probem by adding the assembly as well to the .xaml file. But this did not work for me. That is why I am posting.

我有2个项目。


  1. WPF项目本身。

  2. 类库(这有所有的ViewModels)

WPF项目有参考类库。(应在WPF项目的bin创建这个类库的dll文件)

WPF project has a reference to the Class Library.(Which should create a dll file of this Class Library in the bin of WPF project)

我想引用一个模型类库。
所以,我做了如下:

I want to refer to a model in the class library. So, I did as follows.

    <UserControl x:Class="WPFApplication.Views.SalesScreen"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:productListViewModel="clr-namespace: WPFApplication.CommonInterface.Shared.ViewModels; assembly=WPFApplication.CommonInterface"
             mc:Ignorable="d" 
             d:DesignHeight="820" d:DesignWidth="1280" Loaded="PlaneLoaded">....
....
<productListViewModel:ProductListVM x:Key="ProductsListVMC"/>...

不过还是问题退出,此 ProductListVM 类(模型)存在在 WPFApplication.CommonInterface.Shared.ViewModels 名字空间,它是公共为好。 :)

But still the problem exits, this ProductListVM class(model) exists in the WPFApplication.CommonInterface.Shared.ViewModels name space and it is public as well. :)

错误说:

The name "ProductListVM" does not exist in the namespace "clr-namespace:WPFApplication.CommonInterface.Shared.ViewModels; assembly=WPFApplication.CommonInterface".



我也试过单独建立类库和手动添加的dll文件到WPF项目斌/调试和建造它。但问题退出一样。

I also tried to seperately build the Class Library and add the dll file manually to the WPF project bin/debug and built it. but the problem exits as the same.

有错误列表中的另一个错误也是如此。

there is another error in the error list as well.

Unknown build error, ''clr-namespace:WPFApplication.CommonInterface.Shared.ViewModels; assembly=POS.WPFApplication.CommonInterface' mapping URI is not valid. Line 7 Position 14.'  D:\Dev\WPFApplication\Views\POSViews\SalesScreen.xaml

Error   1   The URI "clr-namespace:WPFApplication.CommonInterface.Shared.ViewModels; assembly=WPFApplication.CommonInterface" is not a valid namespace identifier.  D:\Dev\WPFApplication\Views\POSViews\SalesScreen.xaml



由于我从类模型本身复制的命名空间,不能有拼写错误(99%),

Since I have copied the namespaces from the class model itself, there can not be spelling errors(99%),

您能给我这个帮助快速解决问题。

Can you give me a help on this to solve the problem fast.

在此先感谢。

推荐答案

当你想从引用在WPF项目中的XAML文件的另一个项目,留意以下几点。

When you want to reference from another project in one of your XAML file of WPF project, Watch out for the following.

在我的问题,当我删除之间的空间这些如下图所示 [这是空间]

In my issue, when I removed the space between these as shown below [This is the space].

的xmlns:productListViewModel = CLR命名空间:WPFApplication.CommonInterface.Shared.ViewModels;这是空间] ssembly = WPFApplication.CommonInterface

和它的工作: )

PS:我在VS2012的工作。

PS: I am working in VS2012

我浪费在这个时间的大量:(。

I wasted a big amount of time on this.:(

这篇关于在WPF XAML文件中的另一个项目引用名字空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆