[英]Why am I being told a class does not exist in my namespace when it does?
我正在尝试按照此处的文章向我的项目中添加自定义控件,以便可以这样调用它(“ promptForPhotosetName”):
Popup popTart = new Popup();
popTart.Child = new promptForPhotosetName();
popTart.IsOpen = true;
我在模板控件的基础上向项目添加了自定义控件。
我的自定义控件类(在Photrax名称空间中为IS)包含以下构造函数:
public promptForPhotosetName()
{
this.DefaultStyleKey = typeof(promptForPhotosetName);
}
我在\\ Themes \\ Generic.xaml中有此文件,这是添加自定义控件时创建的另一个文件(以及hintForForPhotsetName.cs):
<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>
但是我得到这个错误:XAML的这两行中,名称空间“ using:Photrax”中都不存在名称“ promptForPhotosetName” :
<Style TargetType="local:promptForPhotosetName">
...还有这个:
<ControlTemplate TargetType="local:promptForPhotosetName">
为什么? 类promptForPhotosetName确实在Photrax命名空间!
听起来就像是设计工具错误。 重建项目应该使设计人员认识到以前从未见过的类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.