show a page inside a window in XAML
17,799
<TabItem>
<Frame Source="MyPage.xaml" />
</TabItem>
Author by
Steinthor.palsson
Updated on June 29, 2022Comments
-
Steinthor.palsson almost 2 years
I have a tabcontrol in my window, inside each tabitem I want to have a different page.
I can achieve this by making a Frame inside the TabItem and in the behind code use for example:frame1.Content = new Pages.MyPage()
How can I do the same thing in XAML?
-
Steinthor.palsson about 13 yearsThe first solution results in an InvalidOperationException: "page can only have window or frame as a parent". The second one, "Frame does not support direct content".
-
dcarneiro about 13 yearsDoes MyPage extends UserControl? If not, which class does it extend?
-
Steinthor.palsson about 13 yearsI don't know. It's just a normal page. How would I know that?
-
Steinthor.palsson about 13 yearshah... that simple. Thanks. It won't show up in the designer though. Maybe it's not possible?
-
Y.Yanavichus about 13 years@steini: I dont't know. I never use designer :)
-
Stígandr over 10 yearssteini: <Frame><Frame.Content><MyPage/></Frame.Content></Frame>