I'm making Windows Phone 7.1 app with Visual Studio Express 2012 for Windows Phone.
I added this namespace to MainPage.xaml:
xmlns:myNameSpace="clr-namespace:MyApp"
And this:
<Grid.Resources>
<myNameSpace:MyClass x:Key="referenceToMyClass" />
</Grid.Resources>
And used like this in same file:
<ListBox Name="MyListBox"
Height="{Binding ElementName=ContentPanel, Path=Height}"
Width="{Binding ElementName=ContentPanel, Path=Width}"
ItemsSource="{StaticResource referenceToMyClass}"
DisplayMemberPath="MyAttribute" />
MyClass looks like this:
namespace MyApp
{
class MyClass : ObservableCollection<AnotherClass>
{
public MyClass()
{
Class temp = new AnotherClass("Example attribute");
Add(temp);
}
public void AddAnotherClass(AnotherClass anotherClass)
{
Add(anotherClass);
}
}
}
So when I try to Debug it on my cellphone I get the following error:
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in System.Windows.dll Additional information: No matching constructor found on type 'MyApp.MyClass'.