2017-02-12 62 views
0

我做了最简单的事情。我打开一个新窗口并在其中放置一个框架,并且我想在框架中显示一个页面。 窗口代码:浏览wpf中的页面不工作

public partial class Window1 : Window 
{ 
    public Window1() 
    { 
     InitializeComponent(); 
     Page1 p = new Page1(); 
     navigator.NavigationService.Navigate(p); 
    } 
} 

导航是帧,在第1页予有黑色背景颜色看出差别。当我运行它时,我仍然看到窗口,而不是应该在框架内的页面。为什么这不起作用?

窗口:enter image description here

页:enter image description here

,但我得到了白色的。

第1页的代码:

<Page x:Class="test.Page1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    mc:Ignorable="d" 
    d:DesignHeight="269" d:DesignWidth="292" 
Title="Page1"> 

<Grid Background="Black"> 

</Grid> 

在CS方面我没有写任何东西。

+0

_page1_的代码是什么? – Ron

+0

我将它添加到问题中。 – EldarGoren

回答

0

您需要设置页面的东西的内容属性能够真正看到它:

<Page x:Class="test.Page1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    mc:Ignorable="d" 
    d:DesignHeight="269" d:DesignWidth="292" 
    Title="Page1"> 
    <Grid Background="Black"> 
     <TextBlock>PAGE1</TextBlock> 
    </Grid> 
</Page> 

一个空的黑色网格是不可见的,但如果你把一个TextBlock它,你应该能够看见了。

+0

我做到了,它仍然无法正常工作。 – EldarGoren

+0

请发布Window1.xaml的标记,然后因为它肯定适用于我。 – mm8