Set Window.Content to a page by XAML?

后端 未结 2 832
刺人心
刺人心 2021-01-12 17:50


        
相关标签:
2条回答
  • 2021-01-12 18:34

    Use a Frame element to show the content of the page.

    <Window> <Frame Source="/Pages/MyPage.xaml"/> </Window>
    
    0 讨论(0)
  • 2021-01-12 18:46

    Try something like this, where MyPageAssembly points to the assembly where your page resides, and MyPage is the name of the Page.

    <Window 
        x:Class="MyWindow" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:MyPageAssembly="clr-namespace:MyPage;assembly=MyPageAssembly"
        Title="ContactsSelector" 
        Height="300" 
        Width="300"
        >
        <Window.Content>
            <MyPageAssembly:MyPage />
        </Window.Content>
    </Window>
    
    0 讨论(0)
提交回复
热议问题