show a page inside a window in XAML

左心房为你撑大大i 提交于 2020-03-18 05:06:33

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!