// Loads every non-loaded problem into the ProblemListBox private void ProblemListBox_LoadAll() { // For every non-loaded problem in ProblemData.Problems (pI = 0-based index) for (int pI = ProblemListBox.Items.Count; pI < ProblemData.Problems.Count; pI++) { // Data prep int pN = pI + 1; Problem P = ProblemData.Problems[pN]; // ListBoxItem' content is a StackPanel StackPanel SP = new StackPanel(); SP.Orientation = Orientation.Horizontal; SP.Children.Add(new TextBlock() { Text = $"{pN}: " }); SP.Children.Add(new TextBlock() { Text = P.Title }); // LBI ListBoxItem LBI = new ListBoxItem() { Content = SP }; // Add LBI to PLB ProblemListBox.Items.Add(LBI); } // Scroll PLB to bottom ProblemListScrollViewer.ScrollToBottom(); }
// Handles scolling when the mouse is inside of the listbox private void ProblemListBox_PreviewMouseWheel(Object sender, MouseWheelEventArgs e) { ProblemListScrollViewer.ScrollToVerticalOffset(ProblemListScrollViewer.VerticalOffset - e.Delta / 3); }