2017-02-12 8 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のため

コード:私は何も書いていないCS側で

<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> 

+0

_page1_のコードは何ですか? – Ron

+0

質問に追加しました。 – EldarGoren

答えて

0

あなたが実際にそれを見ることができるようにするものにページのContentプロパティを設定する必要があります。

<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

関連する問題