C++/WinRT: Hosting TabViewItem content in a dedicated/seperate Frame #9940
Unanswered
michelgerritse
asked this question in
Q&A
Replies: 1 comment
-
Let me answer my own question: The DataContext property of a TabViewItem appears to be the way to go. When programmatically creating the tab item(s), I'm assigning the the desired page to the property like this:
All I need to do is handling the SelectionChanged event like this:
Just a reminder: you need to set Now a follow-up question pops to mind: Would it be possible to bind the DataContext property of the active tab to the Content of my dedicated Frame ? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I was wondering if there is an (easy) way to host the UI content of a TabViewItem into a dedicated Frame ?
Let me explain the situation:
I have a TabView control as the main UI navigation element in my app. All TabVIewItems are created programmatically; some are built into the app, for example a "Home" and a "Settings" item. Other tabs will eventually come from runtime components. All tabs will have their own specific UI content. I have a dedicated Frame in the app, which purpose is to host the UI content from the TabViewItems. The XAML looks something like this:
The reason for this design, among some other reasons, is to have a single Frame (without any other UI elements) to display content when in a fullscreen presentation mode. Think about each TabViewItem hosting a video, and when the item is selected the video will be visible in the Frame.
How can I assign UI content to a TabViewItem, without using the Content property? I think a possible candidate is the DataContext property, but I'm not sure how I could use this. The second part of the question would be how to display the content into the dedicated Frame when handling the
OnTabViewSelectionChanged
event:It is essential that UI content stays valid during the lifetime of the TabViewItem, and not getting re-created every time we navigate to a TabViewItem.
I'm still new to the Windows App SDK / WinUI3 / WinRT (coming from native Win32), so this "problem" might be obvious to some, but I'm having a hard time figuring it out.
Beta Was this translation helpful? Give feedback.
All reactions