2011-03-25 48 views
2

我定義2頁(定義爲導航:頁) 我把在主窗口的兩頁(主窗口的用戶控件)使用Silverlight導航...問題

<Grid x:Name="LayoutRoot" Background="White"> 

    <navigation:Frame 
     Source="/Views/Page1.xaml" 
     x:Name="Page1"> 
    </navigation:Frame> 

    <navigation:Frame 
     Source="/Views/Page2.xaml" 
     x:Name="Page2">     
    </navigation:Frame> 

</Grid> 

現在,當我加載Silverlight應用程序 - 我看到page1已經啓動。 但是..我如何切換到page2?並回到第1頁?

感謝您的任何幫助。

回答

0

首先,在您的示例中,Page2將自第一頁開始在網格上顯示。

其次,導航框架不應該像這樣使用。導航框架與瀏覽器URL匹配,這樣您就可以使用silverlight瀏覽器後退按鈕進行導航。

如果您的應用中有2個導航框,那麼這會搞砸了。

我想你應該只有1個導航框架,從1和Page 2切換。

+0

實際上,導航框架可以像我的示例所示那樣使用。你可以在你的應用中擁有儘可能多的幀。主框架可以處理瀏覽器日誌任何子框架可以將journalownerhip設置爲擁有日誌。 – 2011-03-29 01:40:46

0

你可能無法見第2頁,因爲第1頁佔用了所有的網格行的。將每個框架放在它自己的行中。以下是一頁上兩個框架的示例。 https://bitbucket.org/dbeattie/navdemo/src

<Grid> 
    <Grid> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="1*" /> 
      <RowDefinition Height="1*" /> 
      <RowDefinition Height="1*" /> 
     </Grid.RowDefinitions> 
     <StackPanel Grid.Row="0" 
        Orientation="Vertical"> 
      <TextBlock Text="MainView" /> 
      <Button Content="Load Area1 with Sub3View" 
        Command="{Binding Path=Load1Command}" /> 
      <Button Content="Load Area1 with Sub1View" 
        Command="{Binding Path=Load2Command}" /> 
      <TextBox Text="{Binding Path=DataToPass, Mode=TwoWay}"></TextBox> 
     </StackPanel> 
     <Grid Grid.Row="1"> 
      <Grid.RowDefinitions> 
       <RowDefinition Height=".5*" /> 
       <RowDefinition Height="2*" /> 
      </Grid.RowDefinitions> 
      <TextBlock Text="Area1" /> 
      <nav:Frame Grid.Row="1" 
         Source="{Binding Path=FrameSource}" /> 
     </Grid> 
     <Grid Grid.Row="2"> 
      <Grid.RowDefinitions> 
       <RowDefinition Height=".5*" /> 
       <RowDefinition Height="2*" /> 
      </Grid.RowDefinitions> 
      <TextBlock Text="Area2" /> 
      <nav:Frame Grid.Row="1" 
         JournalOwnership="OwnsJournal" 
         Source="{Binding Path=FrameSource2}" /> 
     </Grid> 
    </Grid> 
</Grid>