public void eventsUpdated() { contentGrid.RowDefinitions.Clear(); contentGrid.Children.Clear(); if (events.Count == 0) { return; } RowDefinition row = new RowDefinition(); double diff = events.ElementAt(0).RawTime - minHour; if (diff < 0) { diff = 0; } row.Height = new GridLength(diff, GridUnitType.Star); contentGrid.RowDefinitions.Add(row); Console.WriteLine("--------"); Console.WriteLine(diff); for (int i = 0; i < events.Count; ++i) { Entry e = events.ElementAt(i); double nextTime = maxHour; if (i < events.Count - 1) { nextTime = events.ElementAt(i + 1).RawTime; } diff = nextTime - e.RawTime; if (diff < 1) { diff = 0; } Console.WriteLine(diff); row = new RowDefinition(); row.Height = new GridLength(diff, GridUnitType.Star); contentGrid.RowDefinitions.Add(row); DockPanel entryPanel = new DockPanel(); entryPanel.VerticalAlignment = System.Windows.VerticalAlignment.Top; Label timeLabel = new Label(); timeLabel.Content = e.When; timeLabel.Style = (Style)Resources["EntryDate"]; DockPanel.SetDock(timeLabel, Dock.Left); entryPanel.Children.Add(timeLabel); Button titleLabel = new Button(); titleLabel.Tag = e.ID; titleLabel.Content = e.What; titleLabel.Style = (Style)Resources["EntryTitle"]; titleLabel.Click += OnEventClick; entryPanel.Children.Add(titleLabel); if (IsTouchable) { titleLabel.BorderThickness = new Thickness(0, 0, 4, 4); titleLabel.BorderBrush = new SolidColorBrush(Colors.DarkGray); } entryPanel.Measure(new Size(ActualWidth, Double.PositiveInfinity)); double x = entryPanel.DesiredSize.Height; row.MinHeight = x; Grid.SetRow(entryPanel, i + 1); contentGrid.Children.Add(entryPanel); } }