简单的XAML到XAML页面导航

时间:2010-12-11 22:02:11

标签: c# silverlight xaml silverlight-4.0

我想简单地从一个.xaml页面导航到另一个页面。我意识到导航模板是为此而构建的,但我不希望下面的主页标题/内容感觉它带来了。使用空白的Silverlight应用程序(C#)我想使用超链接按钮从Page1.xaml移动到Page2.xaml。

在Page1.xaml上我有一个像这样的超链接按钮:

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

这似乎不起作用。请帮忙

1 个答案:

答案 0 :(得分: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个元素。

相关问题