2010-12-11 99 views
1

我試圖簡單地從一個.xaml頁面導航到另一個。我意識到導航模板是爲此而構建的,但我不希望下面的主頁頁眉/內容感覺它會帶來。使用空白Silverlight應用程序(C#)我想使用超鏈接按鈕從Page1.xaml移動到Page2.xaml。簡單的XAML到XAML頁面導航

上的Page1.xaml我有一個超鏈接按鈕,這樣的:

<HyperlinkButton Content="Preview Report" Height="24" HorizontalAlignment="Stretch" Margin="98,296,377,21" Name="hyperlinkButton1" NavigateUri="/Page2.xaml" /> 

這似乎並沒有工作。請幫助

回答

0

您需要在MainPage中有一個導航框架才能支持此功能。從空白的Silverlight應用程序開始。

修改MainPage.xaml中的樣子: -

<UserControl x:Class="StackoverflowSpikes.NavPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"    
    mc:Ignorable="d" 
    d:DesignHeight="300" d:DesignWidth="400"> 

    <Grid x:Name="LayoutRoot" Background="White"> 
     <navigation:Frame Source="/Page1.xaml" /> 
    </Grid> 
</UserControl> 

添加兩個或更多的導航頁面對您的項目。現在您可以爲它們添加HyperLinkButton元素。

相關問題