【发布时间】:2013-01-27 20:32:33
【问题描述】:
我正在使用 Visual Studio Express 2012 for Windows Phone 制作 Windows Phone 7.1 应用程序。
我将此命名空间添加到 MainPage.xaml:
xmlns:myNameSpace="clr-namespace:MyApp"
还有这个:
<Grid.Resources>
<myNameSpace:MyClass x:Key="referenceToMyClass" />
</Grid.Resources>
并在同一个文件中这样使用:
<ListBox Name="MyListBox"
Height="{Binding ElementName=ContentPanel, Path=Height}"
Width="{Binding ElementName=ContentPanel, Path=Width}"
ItemsSource="{StaticResource referenceToMyClass}"
DisplayMemberPath="MyAttribute" />
MyClass 如下所示:
namespace MyApp
{
class MyClass : ObservableCollection<AnotherClass>
{
public MyClass()
{
Class temp = new AnotherClass("Example attribute");
Add(temp);
}
public void AddAnotherClass(AnotherClass anotherClass)
{
Add(anotherClass);
}
}
}
所以当我尝试在我的手机上调试它时,我收到以下错误:
System.Windows.dll 中发生了“System.Windows.Markup.XamlParseException”类型的第一次机会异常 附加信息:在类型“MyApp.MyClass”上找不到匹配的构造函数。
【问题讨论】:
标签: c# silverlight windows-phone-7 xaml exception-handling