--- a/ui/winui/container.cpp Tue Oct 03 16:30:42 2023 +0200 +++ b/ui/winui/container.cpp Tue Oct 03 21:10:15 2023 +0200 @@ -530,7 +530,7 @@ return uitabview; } -UiNavigationTabView::UiNavigationTabView(UiObject* obj, NavigationView NavigationView, UiTabViewArgs args, enum UiNavigationViewType type) { +UiNavigationTabView::UiNavigationTabView(UiObject* obj, NavigationView navigationview, UiTabViewArgs args, UiTabViewType type) { this->current = obj; this->navigationview = navigationview; this->type = type; @@ -538,6 +538,12 @@ this->spacing = args.spacing; this->columnspacing = args.columnspacing; this->rowspacing = args.rowspacing; + + if (type == UI_TABVIEW_NAVIGATION_TOP) { + navigationview.PaneDisplayMode(NavigationViewPaneDisplayMode::Top); + } + + navigationview.SelectionChanged({ this, &UiNavigationTabView::SelectionChanged }); } UiObject* UiNavigationTabView::AddTab(const char* label) { @@ -552,12 +558,14 @@ // sub container Grid subcontainer = Grid(); - //item.Content(subcontainer); - navigationview.MenuItems().Append(item); + if (pages.size() == 0) { + navigationview.Content(subcontainer); + navigationview.SelectedItem(item); + } - Button b1 = Button(); - b1.Content(box_value(L"Test")); - navigationview.Content(b1); + navigationview.MenuItems().Append(item); + auto page = std::tuple<NavigationViewItem, FrameworkElement>{ item, subcontainer }; + pages.push_back(page); return create_subcontainer_obj(current, subcontainer, this->subcontainer, margin, spacing, columnspacing, rowspacing); } @@ -566,16 +574,51 @@ return navigationview; } -static UiTabView* tabview_navigationview_create(UiObject* obj, UiTabViewArgs args) { +void UiNavigationTabView::SelectionChanged(NavigationView const& sender, NavigationViewSelectionChangedEventArgs const& args) { + for (auto page : pages) { + NavigationViewItem item = std::get<0>(page); + FrameworkElement elm = std::get<1>(page); + if (item == navigationview.SelectedItem()) { + navigationview.Content(elm); + break; + } + } +} + +static UiTabView* tabview_navigationview_create(UiObject* obj, UiTabViewArgs args, UiTabViewType type) { NavigationView navigationview = NavigationView(); - UiNavigationTabView* tabview = new UiNavigationTabView(obj, navigationview, args, UI_NAVIGATIONVIEW_SIDE); + UiNavigationTabView* tabview = new UiNavigationTabView(obj, navigationview, args, type); + navigationview.IsBackButtonVisible(NavigationViewBackButtonVisible::Collapsed); + navigationview.IsSettingsVisible(false); return tabview; } UIWIDGET ui_tabview_create(UiObject* obj, UiTabViewArgs args) { UiTabViewType type = args.tabview == UI_TABVIEW_DEFAULT ? UI_TABVIEW_NAVIGATION_TOP2 : args.tabview; - UiTabView *tabview = tabview_navigationview_create(obj, args); + UiTabView* tabview = nullptr; + switch (type) { + default: { + tabview = tabview_pivot_create(obj, args); + break; + } + case UI_TABVIEW_DOC: { + tabview = tabview_main_create(obj, args); + break; + } + case UI_TABVIEW_NAVIGATION_SIDE: { + tabview = tabview_navigationview_create(obj, args, type); + break; + } + case UI_TABVIEW_NAVIGATION_TOP: { + tabview = tabview_navigationview_create(obj, args, type); + break; + } + case UI_TABVIEW_NAVIGATION_TOP2: { + tabview = tabview_pivot_create(obj, args); + break; + } + } UiTabViewContainer* ctn = new UiTabViewContainer(tabview); // add frame to the parent container