private void Window_Loaded(object sender, RoutedEventArgs e) { // do this to get the HWND and set up the window hook WindowInteropHelper helper = new WindowInteropHelper(this); HwndSource.FromHwnd(helper.Handle).AddHook(HwndSourceHookHandler); port = new WS4000HidPort(); port.RegisterHandle(helper.Handle); _dbAccess = new DbAccess(); _timeOffsets = new TimeOffsets(); _weatherSnapshots = _dbAccess.Load(_dbAccess.FirstDate, _dbAccess.LastDate); stackPanel1.DataContext = _dbAccess; //cmbToInterval.DataContext = _timeOffsets; cmbToInterval.Items.Clear(); foreach (TimeOffset offset in _timeOffsets.list) { cmbToInterval.Items.Add(offset); cmbFromInterval.Items.Add(offset); } cmbToInterval.SelectedIndex = 0; cmbFromInterval.SelectedIndex = 0; // Pre-load the two DatePickers dateFrom.SelectedDate = _dbAccess.FirstDate; dateTo.SelectedDate = _dbAccess.LastDate; System.Windows.Data.CollectionViewSource dbAccessViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("dbAccessViewSource"))); // Load data by setting the CollectionViewSource.Source property: // dbAccessViewSource.Source = [generic data source] weatherSnapshotViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("weatherSnapshotViewSource"))); // Load data by setting the CollectionViewSource.Source property: weatherSnapshotViewSource.Source = _weatherSnapshots; }