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.Markup.XamlParseException' の初回例外が System.Windows.dll で発生しました 追加情報: タイプ 'MyApp.MyClass' で一致するコンストラクターが見つかりませんでした。