首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从选择按钮导航到一个全景项(窗格)到另一个全景项?

如何从选择按钮导航到一个全景项(窗格)到另一个全景项?
EN

Stack Overflow用户
提问于 2013-12-06 00:33:50
回答 3查看 757关注 0票数 0

我是Windows8开发的新手。为了我在大学的最后一年项目,我必须创建一个Windows8手机应用程序-我正在处理应用程序的我的主页,我已经在MainPage.xaml中设置为全景页

我想知道如何使用PanoramaControl.DefaultItem属性从一个全景项移动到另一个全景项,只需单击一个按钮。

我有一个“主页”全景项目与导航按钮,我想导航到其他全景项目在同一页面内。我设置的一个全景项目是一个叫做“我的建议”的项目。

例如,用户选择位于“主页”全景项目中的“我的建议”按钮,则应用程序将转到该特定全景项目,即“我的日记”

以下是我到目前为止为在MainPage.xaml中设置全景项目而创建的代码-

代码语言:javascript
复制
<!--Panorama item one-->
        <phone:PanoramaItem Header="Home">


<!-- Homepane Stack Panel-->
<StackPanel x:Name="HomePanel" Grid.Row="1" Margin="0,-42,0,0">
                <Button x:Name="My_Advice" Content="My Advice" HorizontalAlignment="Center" Height="74" Margin="124,0,100,0" 
                        VerticalAlignment="Top" Width="200" Background="#3FFFFFFF" BorderBrush="#3FFFFFFF"/>
                <Button Grid.Row="1" Content="My Journal" HorizontalAlignment="Center" Height="74" Margin="124,0,100,0"
                        VerticalAlignment="Top" Width="200" Background="#3FFFFFFF" BorderBrush="#3FFFFFFF"/>
                <Button Grid.Row="2" Content="My Vibes" HorizontalAlignment="Center" Height="74" Margin="124,0,100,0"
                        VerticalAlignment="Top" Width="200"  Background="#3FFFFFFF" BorderBrush="#3FFFFFFF"/>
                <Button Grid.Row="3" Content="My Guidance" HorizontalAlignment="Center" Height="74" Margin="124,0,100,0"
                        VerticalAlignment="Top" Width="200"  Background="#3FFFFFFF" BorderBrush="#3FFFFFFF"/>
                <Button Grid.Row="4" Content="My Support" HorizontalAlignment="Center" Height="74" Margin="119,0,100,0"
                        VerticalAlignment="Top" Width="200" Background="#3FFFFFFF" BorderBrush="#3FFFFFFF"/>
                <Button Grid.Row="5" Content="Help" HorizontalAlignment="Center" Height="74" Margin="119,0,100,0" 
                         Background="#3FFFFFFF" BorderBrush="#3FFFFFFF" VerticalAlignment="Top" Width="200"/>

            </StackPanel>
        </phone:PanoramaItem>

        <!--Panorama item two-->
        <phone:PanoramaItem Header="My Advice">
            <Grid  Grid.Row="1" VerticalAlignment="Top" Width="399">

                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

         <Button x:Name="My_Anxiety101" Content="My Anxiety Info" Grid.Row="0"       Height="106" Width="255" Background="#3FFFFFFF" BorderBrush="#3FFFFFFF" Tap="My_Anxiety101_Tap"/>  
         <Button x:Name="My_Situations" Content="My Situations" Grid.Row="2" Height="106" Width="255" Background="#3FFFFFFF" BorderBrush="#3FFFFFFF" Tap="My_Situations_Tap"/>

            </Grid>
        </phone:PanoramaItem>

Mainpage.xaml.cs

代码语言:javascript
复制
namespace IME
{

public partial class MainPage : PhoneApplicationPage
{
    public MainPage()
    {
        InitializeComponent();
    }

    //--------------------Navigation Button Event Handlers-

    //My Advice Section
    private void My_Anxiety101_Tap(object sender, System.Windows.Input.GestureEventArgs e)
    {
        NavigationService.Navigate(new Uri("/Advice/MyAnxiety101.xaml", UriKind.Relative));
    }
    private void My_Situations_Tap(object sender, System.Windows.Input.GestureEventArgs e)
    {
        NavigationService.Navigate(new Uri("/Advice/MySituations.xaml", UriKind.Relative));
    }

如果有任何信息丢失或有什么不合理的地方,请告诉我。提前感谢

EN

回答 3

Stack Overflow用户

发布于 2014-01-03 20:13:16

你需要在每个按钮上放一个名字,双击它们来创建方法,然后使用NavigationService.Navigate(新的Uri等)将你带到你想要的页面(PanoramaPage2,例如)

票数 0
EN

Stack Overflow用户

发布于 2014-03-12 16:59:00

如果要导航到第二个项目:

代码语言:javascript
复制
private void My Advice_Click(object sender, EventArgs e)
{
    ParanomaPageName.SelectedIndex = 1;
}

如果您想导航到第三项:

代码语言:javascript
复制
private void My Advice_Click(object sender, EventArgs e)
{
    ParanomaPageName.SelectedIndex = 2;
}

诸若此类。

票数 0
EN

Stack Overflow用户

发布于 2014-11-18 06:17:21

代码语言:javascript
复制
    public enum PanoramaItem
    {
        None = -1, Account, Game, Help
    }

    public void PanoramaNavigateTo(PanoramaItem item)
    {
        panorama.DefaultItem = panorama.Items[(int)item];
    }

    private void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        viewGame.cmdPlay.Click += new RoutedEventHandler(CmdPlayGame);
    }


    private void CmdPlayGame(object sender, RoutedEventArgs e)
    {
        PanoramaNavigateTo(PanoramaItem.Game);
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20405470

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档