[ACCEPTED]-Set Window.Content to a page by XAML?-window

Accepted answer
Score: 12

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

<Window> <Frame Source="/Pages/MyPage.xaml"/> </Window>
Score: 4

Try something like this, where MyPageAssembly points to 2 the assembly where your page resides, and 1 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>

More Related questions