Ok, I’m no newbie at programming or C# as such, I just can’t seem to get WPF’s databinding straight in my head. My colleagues are raving about it (and yes, I will ask them as well) but right now I’m stumped.
Here’s what I’d like to do for starters:
As an example I’ve got a list of things like this:
List<Thing> thingList = Source.getList();
Now normally I’d go
foreach(Thing t in thingList)
{
//add thing to combobox
}
But from what I can gather is that I can somehow not do this but use a databinding to populate the combobox for me.
What I can’t seem to get is where do I put the ‘thingList’? Do I make it a separate property somewhere? Where do I put that property?
I feel very stupid at the moment, as I’ve been struggling with this for a while now and I can’t find any examples out there that make me understand this – probably very simple – concept.
Anyone out there willing to help me or point me at some step-by-step guide I might have missed?
Use
ObservableCollection<T>for databinding in WPF. Where T is your class. See example belowNow in XAML. Go to resource tag
xmnls:cwill give you option to choose the class. Here you can choose c,d ,e x whatever but be sure it should be used earlier