Of course, you can become attached to it. I shifted the following code:
public partial class MainWindow : Window { private readonly ObservableCollection<Tuple<DateTime, DateTime>> _dates = new ObservableCollection<Tuple<DateTime,DateTime>>(); public ObservableCollection<Tuple<DateTime, DateTime>> Dates { get { return _dates; } } public MainWindow() { DataContext = this; InitializeComponent(); PopulateList(); } private void PopulateList() { _dates.Add(new Tuple<DateTime, DateTime>(DateTime.Now, DateTime.Now)); _dates.Add(new Tuple<DateTime, DateTime>(DateTime.Now, DateTime.Now)); _dates.Add(new Tuple<DateTime, DateTime>(DateTime.Now, DateTime.Now)); } }
And XAML:
<Window x:Class="GuiScratch.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <ListBox ItemsSource="{Binding Dates}"/> </Grid> </Window>
When I run this, I see a list of items with two dates merged into a list of items.
However, whether you want to do this or not, perhaps more depends on the specific context. If the need to have very pluggable types of bindings makes sense (for example, the date time can change to a string or int), this might be a good option. If you do not, I would say that you are better off messing with something more expressive.
source share