If I want to bind something like a combobox in the code-behind I have no problem at all. Something like :
List<string> strings = new List<string>();
AddStringsFromDataSourceToList(strings);
comboBox1.ItemSource = strings;
As far as I can tell, there is no quick and dirty way to do this in XAML. For all of the praise wpf is receiving for its super simple databinding, something this simple seems far easier to just do in C#. Is there an easier way to do this than creating DependencyProperty wrappers and adding them as resources without much help from intellisense or all that goes into ObservableCollections? I understand that its not impossible, but I must be missing something if such a simple task seems so in depth…
EDIT: To clarify, adding dynamic Lists is the issue here, not static arrays. It is super easy to add items manually, as many have pointed out.
Sure there is:
There are other syntaxes depending on your goal that are nearly as simple – using resources or inline itemssources, or grouped data.. even xml data. Don’t throw up your hands in frustration because the first thing you tried wasn’t easy – wpf is worth the learning curve, in my opinion.
WPF gets praise because it makes separating the visuals from the behavior much easier than windows forms, and because it makes creating nice visual effects much much easier, not because it makes it easier to do trivial examples. However, in this case – it is easier to do the trivial example.
With your edit Where do you want to pull them from? You don’t have to create dependency properties or observable collections by any means. A simple list property will do (I prefer to use a collectionviewsource in the xaml in that case). Also, don’t forget that you don’t need to use all XAML if you hate it. But if you design for WPF instead of in spite of it you’ll find a lot of tasks (like this one) easy.