private void Expander_Initialized(object sender, EventArgs e) { Expander ex = (Expander)sender; Tasks t = new Tasks(); StackPanel sp = new StackPanel(); foreach (TaskData td in t.GetTasksByCategory(ex.Header.ToString())) { if (td.IsComplete) continue; Label l = new Label(); l.Content = td.Subject; l.MouseLeftButtonDown += new MouseButtonEventHandler(l_MouseLeftButtonDown); sp.Children.Add(l); } sp.Margin = new Thickness(25, 0, 0, 0); ex.Content = sp; }