PDA

View Full Version : Data Binding to CLR objects, wont work?



sandra_svensson
October 26th, 2008, 06:02 AM
Okey, Ive try to solve this problem for hours now and dont, at all, know what Im doing so wrong.

Im up 2 the tutorial Data Binding to CLR Objects (http://www.kirupa.com/net/clr_data_binding_pg1.htm), and have also done exactly what it tells me to do, all the way. Which means Ive made a new C# class in VisualStudio and when I go back to Blend again, I can see the class in my projectfiles panel but when I will bind it with +CLR objects my class is not showing up there :S

Any ideas what to do? :S

http://www.kirupa.com/forum/attachment.php?attachmentid=48271&stc=1&d=1225011651

kirupa
October 26th, 2008, 04:51 PM
Hi Sandra,
Is the namespace for your FontCollection.cs file the same as that of your Window1.xaml / cs file? The reason is, if I try the following code, I am able to see FontCollection appear in the data pane:

public partial class Page : UserControl
{
public Page()
{
InitializeComponent();
}
}

class FontCollection : ObservableCollection<FontFamily>
{
public FontCollection()
{
/*
foreach (FontFamily f in Fonts.SystemFontFamilies)
{
//this.Add(f);
}*/
}
}

Cheers!
Kirupa