问题
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?
回答1:
<TabItem>
<Frame Source="MyPage.xaml" />
</TabItem>
回答2:
you probably don't need the frame. Something like this should work.
<TabControl>
<TabItem>
<MyPage Name=frame1 />
</TabItem>
<TabItem>
<MyPage Name=frame2 />
</TabItem>
</TabControl>
If you want the frame just do:
<TabItem>
<Frame>
<MyPage Name=frame1 />
</Frame>
</TabItem>
来源:https://stackoverflow.com/questions/5477871/show-a-page-inside-a-window-in-xaml