C# 名称<&燃气轮机;命名空间中不存在<&燃气轮机;(图书馆工程)
我是C#/Windows应用商店应用程序开发新手,遇到了一个问题: 我要走了C# 名称<&燃气轮机;命名空间中不存在<&燃气轮机;(图书馆工程),c#,wpf,xaml,wpf-controls,C#,Wpf,Xaml,Wpf Controls,我是C#/Windows应用商店应用程序开发新手,遇到了一个问题: 我要走了 名称“CustomTemplate1”在命名空间“using:QSTLibrary.WIN8”中不存在。 我从事的项目有两个库(一个是便携库(没有任何GUI)和一个特定于平台的库(Win store apps)),还有一个基于这两个库的启动项目 在特定于平台的库中,我想添加一个模板控件,但是当使用add->new item->templated control添加它时,自动生成的“Themes”文件夹中的Generic
名称“CustomTemplate1”在命名空间“using:QSTLibrary.WIN8”中不存在。
我从事的项目有两个库(一个是便携库(没有任何GUI)和一个特定于平台的库(Win store apps)),还有一个基于这两个库的启动项目
在特定于平台的库中,我想添加一个模板控件
,但是当使用add->new item->templated control
添加它时,自动生成的“Themes”文件夹中的Generic.xaml出现了上述错误
下面是Generic.xaml:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:QSTLibrary.WIN8">
<Style TargetType="local:CustomTemplate1"> //HERE IS THE PROBLEM !!!!
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:CustomTemplate1">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
QSTLibrary.WIN8是特定于平台的库
请帮我解决这个问题。我已经通过复制Generic.xaml的内容解决了这个问题,删除Generic.xaml,构建,在Themes文件夹下再次添加一个新的xaml文件(命名为Generic.xaml)并粘贴Generic.xaml的初始内容。重新构建并运行。我的结论是,我必须首先编译包含CustomTemplate1.cs的lib,在编译之后,lib将能够添加对CustomTemplate1.cs的引用。由于最初的错误,lib没有被编译,因此删除带有错误的文件,编译,再次添加xaml是我解决这个问题的方法。看起来像是Visual Studio的一个bug。我通过复制Generic.xaml的内容、删除Generic.xaml、构建、在主题文件夹下再次添加一个新的xaml文件(命名为Generic.xaml)并粘贴Generic.xaml的初始内容来解决它。重新构建并运行。我的结论是,我必须首先编译包含CustomTemplate1.cs的lib,在编译之后,lib将能够添加对CustomTemplate1.cs的引用。由于最初的错误,lib没有被编译,因此删除带有错误的文件,编译,再次添加xaml是我解决这个问题的方法。对我来说,这似乎是Visual Studio的一个bug。尝试注释掉有问题的样式重新编译、取消注释和生成。Visual使用编译后的dll验证引用元素的存在。@AlexandruCircus,您是否尝试过
xmlns:local=“clr namespace:QSTLibrary.WIN8”
?@dkozl-是的,我尝试过,它说QSTLibrary.WIN8没有定义为命名空间或类似的东西that@Rafal-我对整个xaml、rebuid、uncomment进行了注释,和build,但错误仍然存在。@AlexandruCircus,与ResourceDictionary
位于同一程序集中的QSTLibrary.WIN8.CustomTemplate1
?请尝试注释掉有问题的样式,重新编译、取消注释并生成。Visual使用编译后的dll验证引用元素的存在。@AlexandruCircus,您是否尝试过xmlns:local=“clr namespace:QSTLibrary.WIN8”
?@dkozl-是的,我尝试过,它说QSTLibrary.WIN8没有定义为命名空间或类似的东西that@Rafal-我对整个xaml、rebuid、uncomment进行了注释,和build,但错误仍然存在。@AlexandruCircus,QSTLibrary.WIN8.CustomTemplate1
与您的ResourceDictionary
在同一程序集中吗?
using System;
using System.Collections.Generic;
using System.Linq;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Documents;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
// The Templated Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234235
namespace QSTLibrary.WIN8
{
public sealed class CustomTemplate1 : Control
{
public CustomTemplate1()
{
this.DefaultStyleKey = typeof(CustomTemplate1);
}
}
}