首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >名称<>在名称空间<>中不存在(用于库项目)

名称<>在名称空间<>中不存在(用于库项目)
EN

Stack Overflow用户
提问于 2013-09-25 09:52:34
回答 1查看 2.8K关注 0票数 1

我是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:

代码语言:javascript
复制
<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:

代码语言:javascript
复制
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是特定于平台的库。

请帮我解决这个问题。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-25 11:00:26

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

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19001635

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档