我是C#/Windows商店应用程序开发的新手,我遇到了一个问题:我
The name "CustomTemplate1" does not exist in the namespace "using:QSTLibrary.WIN8"
我从事的项目有2个库(一个是可移植的(没有任何GUI)和一个特定于平台的项目(Win存储应用程序)),以及一个基于这两个库的启动项目。
在特定于平台的库中,我想添加一个templated control,但是当使用add -> new item -> templated control添加它时,自动生成的“主题”文件夹中的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>以下是CustomTemplate1:
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);
}
}
}QSTLibrary.WIN8是特定于平台的库。

请帮我解决这个问题。
发布于 2013-09-25 11:00:26
我已经通过复制Generic.xaml的内容、删除Generic.xaml、构建、在Themes文件夹下添加一个新的xaml文件(命名为Generic.xaml)并粘贴Generic.xaml的初始内容来解决这个问题。再建一次然后开始工作。我的结论是,我必须首先编译包含CustomTemplat1.cs的lib,在此编译之后,lib将能够添加对CustomTemplat1.cs的引用。由于初始错误,库没有编译,所以删除带有错误的文件,编译,再添加xaml是我解决这个问题的方法。对我来说像是的bug。
https://stackoverflow.com/questions/19001635
复制相似问题