private void ListBoxItem_Selected(object sender, RoutedEventArgs e) { ListBoxItem item = sender as ListBoxItem; SlideButtonControl button = item.Content as SlideButtonControl; CurrentSlide = button.slide; item.BringIntoView(); DisplaySlide(CurrentSlide); }
public void AddSlide(ISlide slide, bool addToPresentation = true) { int selectedIndex = SlideButtonsListBox.SelectedIndex; if (selectedIndex == -1) { selectedIndex = Presentation.Slides.Count; } if (addToPresentation == true) { if (selectedIndex >= Presentation.Slides.Count) { Presentation.AddSlide(slide); } else { selectedIndex++; Presentation.InsertSlideAt(selectedIndex, slide); } } CurrentSlide = slide; DisplaySlide(CurrentSlide); CurrentPage.Initailize(Presentation, CurrentSlide); //Create Visual For Stack Panel SlideButtonControl button = new SlideButtonControl(); button.Margin = new Thickness(0, 2, 0, 2); button.SetIcon(CurrentSlide.Icon); button.Initialize(CurrentSlide); ListBoxItem listBoxItem = new ListBoxItem(); listBoxItem.Content = button; listBoxItem.Selected += ListBoxItem_Selected; SlideButtonsListBox.SelectedItem = listBoxItem; if (selectedIndex >= Presentation.Slides.Count) { SlideButtonsListBox.Items.Add(listBoxItem); } else { SlideButtonsListBox.Items.Insert(selectedIndex, listBoxItem); } UpdateDisplay(); }