名称 <>不存在于命名空间 <>(对于图书馆项目) [英] The name <> does not exist in the namespace <> (for Library project)

查看:19
本文介绍了名称 <>不存在于命名空间 <>(对于图书馆项目)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 C#/Windows 商店应用程序开发的新手,但我遇到了一个问题:我要了

I'm new to C#/Windows store apps development and I have a problem: I'm getting

命名空间using:QSTLibrary.WIN8"中不存在名称CustomTemplate1"

我从事一个项目,该项目有 2 个库(一个可移植的(没有任何 GUI)和一个特定于平台的(Win 商店应用程序))和一个基于这两个库的启动项目.

I work on a project which has 2 libraries (one portable(without any GUI) and one platform specific(Win store apps)) and a startup project which is based on these 2 libs.

在特定于平台的库上,我想添加一个模板化控件,但是在使用add ->新项目 ->模板化控件 来自自动生成的Themes"文件夹的 Generic.xaml 有上述错误.

On the platform-specific library I want to add a templated control, but when adding it using the add -> new item -> templated control the Generic.xaml from the auto-generated "Themes" folder has the above error.

这是 Generic.xaml:

Here is 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:​​

Here is 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 是平台特定的库

QSTLibrary.WIN8 is the platform-specific library

请帮我解决这个问题.

推荐答案

我已经通过复制 Generic.xaml 的内容解决了,删除 Generic.xaml,构建,在 Themes 文件夹下重新添加一个新的 xaml 文件(将其命名为 Generic.xaml)并粘贴 Generic.xaml 的初始内容.再次构建并运行.我的结论是,我必须首先编译包含 CustomTemplate1.cs 的库,在此编译之后,该库将能够添加对 CustomTemplate1.cs 的引用.由于最初的错误,lib 没有编译,所以删除有错误的文件,编译,再次添加 xaml 是我解决这个问题的方法.对我来说看起来像是 Visual Studio 错误.

I've solve it by copying the content of the Generic.xaml, delete the Generic.xaml, build, add again a new xaml file under Themes folder (name it Generic.xaml) and paste the initial content of the Generic.xaml. build again and works. My conclusion is that I must first compile the lib containing the CustomTemplate1.cs and after this compile, the lib will be able to add references to the CustomTemplate1.cs. Because of the initial error, the lib didn't compiled, so removing the file with the error, compiling, adding again the xaml was my way to solve this issue. Looks like a Visual Studio bug for me.

这篇关于名称 &lt;&gt;不存在于命名空间 &lt;&gt;(对于图书馆项目)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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