我试图跟随这篇文章将一个自定义控件添加到我的项目中,这样我就可以像这样调用它("promptForPhotosetName"):
Popup popTart = new Popup();
popTart.Child = new promptForPhotosetName();
popTart.IsOpen = true;我在基于模板控件的项目中添加了一个自定义控件。
我的自定义控件类(位于Photrax命名空间中)包含以下构造函数:
public promptForPhotosetName()
{
this.DefaultStyleKey = typeof(promptForPhotosetName);
}我在\Themes\Generic.xaml中有这样的内容,它是在我添加自定义控件时创建的另一个文件(连同promptForPhotsetName.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>然而,我得到了这个错误:名称"promptForPhotosetName“在名称空间”using:Photrax“中不存在。
<Style TargetType="local:promptForPhotosetName">...and这个:
<ControlTemplate TargetType="local:promptForPhotosetName">为什么?类promptForPhotosetName确实在Photrax命名空间中!
发布于 2014-10-18 06:11:56
听起来只是设计工具的错误。重建项目应该让设计者认识到以前从未见过的类型。
https://stackoverflow.com/questions/26433054
复制相似问题