简体   繁体   English

简单的XAML到XAML页面导航

[英]Simple XAML to XAML page navigation

I am trying to simply navigate from one .xaml page to another. 我试图简单地从一个.xaml页面导航到另一页面。 I realize that the navigation template is built for this but I do not want the mainpage header / content below feel that it brings. 我意识到导航模板是为此而构建的,但是我不希望下面的主页标题/内容带来它。 Using a blank Silverlight application (C#) I want to move from Page1.xaml to Page2.xaml using a hyperlink button. 使用我想从移动的Page1.xaml使用超链接按钮Page2.xaml空白Silverlight应用程序(C#)。

On Page1.xaml I have a hyperlink button like this: 在Page1.xaml上,我有一个像这样的超链接按钮:

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

this doesn't seem to work. 这似乎不起作用。 Please help 请帮忙

You will need a navigation frame in your MainPage in order to support this. 为了支持此功能,您将需要在MainPage中使用一个导航框架。 Start with blank Silverlight Application. 从空白的Silverlight应用程序开始。

Modify MainPage.xaml to look like:- 修改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>

Add two or more Navigation Page's to your project. 将两个或多个导航页面添加到您的项目。 Now you can add HyperLinkButton elements to them. 现在,您可以向其中添加HyperLinkButton元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM