为什么我被告知类在我的名称空间中不存在? [英] Why am I being told a class does not exist in my namespace when it does?

查看:102
本文介绍了为什么我被告知类在我的名称空间中不存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试遵循此处的文章,将自定义控件添加到我的项目中,以便我可以这样调用它( promptForPhotosetName):

I am trying to follow the article here to add a custom control to my project so that I can call it ("promptForPhotosetName") like so:

Popup popTart = new Popup();
popTart.Child = new promptForPhotosetName();
popTart.IsOpen = true;

我在模板控件的基础上向项目添加了自定义控件。

I added a Custom Control to my project based on Templated Control.

我的自定义控件类(位于Photrax命名空间中)包含以下构造函数:

My custom control class (which IS in the Photrax namespace) contains this constructor:

public promptForPhotosetName()
{
    this.DefaultStyleKey = typeof(promptForPhotosetName);
}

我在\Themes\Generic.xaml中有这个当我添加自定义控件时创建的其他文件(以及promptForPhotsetName.cs):

I have this in \Themes\Generic.xaml, which is the other file (along with promptForPhotsetName.cs) that was created when I added the Custom Control:

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Photrax">

    <Style TargetType="local:promptForPhotosetName">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:promptForPhotosetName">
                    <StackPanel Orientation="Vertical">
                        <ListBox >
                            <ListBoxItem>
                                <StackPanel  Orientation="Horizontal">
                                    <Image Source="Windows 8.jpg" Height="200" Width="300" Stretch="Fill"></Image>
                                    <Image Source="Windows_8.jpg" Height="200" Width="300"   Stretch="Fill"></Image>
                                    <Image Source="windows8(1).jpg" Height="200" Width="300"   Stretch="Fill">
                                    </Image>
                                </StackPanel>
                            </ListBoxItem>
                        </ListBox>
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

我却收到此错误:名称 promptForPhotosetName在名称空间中不存在在这两个XAML行上都使用using:Photrax。

<Style TargetType="local:promptForPhotosetName">

...而这个:

<ControlTemplate TargetType="local:promptForPhotosetName">

为什么?类 promptForPhotosetName 确实在Photrax名称空间中!

Why? The class promptForPhotosetName IS indeed in the Photrax namespace!

推荐答案

听起来像只是设计工具错误。重建项目应该使设计人员认识到以前从未见过的类型。

Sounds like just the design tools error. Rebuilding the project should make the designer recognize the types it hasn't seen before.

这篇关于为什么我被告知类在我的名称空间中不存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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