public void SetTabItem(int bookNumber, int chapterNumber, int paragraphNumber, bool newTab) { if (WelcomeBubble.Visibility == Visibility.Visible) { WelcomeBubble.Visibility = Visibility.Collapsed; AddTabButton.Visibility = Visibility.Visible; } _tickEvent.Triger(() => { Chapter chapter = new Chapter(bookNumber, chapterNumber, paragraphNumber); CustomTabViewItem customTabViewItem = new CustomTabViewItem(chapter); if (newTab || AppData.ChapterCount() == 0) { AppData.AddChapter(customTabViewItem); AppData.SetSelectedItem(customTabViewItem.TabItem); MyTabView.Items.Add(customTabViewItem.TabItem); _tickEvent.Triger(() => { MyTabView.SelectedIndex = MyTabView.Items.Count - 1; }, 3, "Set index 1"); } else { AppData.CustomTabViewItems[AppData.SelectedIndex] = customTabViewItem; MyTabView.Items[MyTabView.SelectedIndex] = customTabViewItem.TabItem; _tickEvent.Triger(() => { MyTabView.SelectedIndex = AppData.SelectedIndex; }, 3, "Set index 2"); } }, 3, "SetTabItem"); }
public static void AddChapter(CustomTabViewItem customTabViewItem) { Debug.Assert(IndexOfItem(customTabViewItem.TabItem) < 0); CustomTabViewItems.Add(customTabViewItem); }