If I have a List<Tuple<DateTime,DateTime>> can I bind that to list box in wpf? I know of course I can bind to dictionaries or whatever but in this cause I need to send back a list that could possible have identical values so it makes sense (or seems to) make sense to have a list of tuples? Anyone got any thoughts?
Share
Sure, you can bind to it. I threw together the following code behind:
And XAML:
When I run that, I see a list of items with two datetimes concatenated as list members.
That said, whether you want to do this or not probably depends more on specific context. If the need to have very pluggable binding types makes sense (i.e. date time may change to string or int), this may be a good option. If you don’t, I’d say you’d be better off binding to something more expressive.