0

我有 3 个带有鼠标按下事件的图像,如下所示:

        private void button12_MouseDown(object sender, MouseButtonEventArgs e) // Back to choose story menu page.
    {

       //if button 2 is pressed then show FoodKing
      // if button 1 is pressed then show Grasshopper
        stackPanelHome.Visibility = System.Windows.Visibility.Hidden;
        pageTransition1.Visibility = System.Windows.Visibility.Visible;
        pageTransition1.ShowPage(What to put in here?);


    }

    private void button2_MouseDown(object sender, MouseButtonEventArgs e) // Food fit for a king.
    {
        FoodKing controlpage = new FoodKing(); // Calling user control page          
        stackPanelHome.Visibility = System.Windows.Visibility.Hidden;
        pageTransition1.Visibility = System.Windows.Visibility.Visible;
        pageTransition1.ShowPage(controlpage); 

    }

private void button1_MouseDown(object sender, MouseButtonEventArgs e) // Grasshopper
{
    GrasshopperMenu controlpage = new GrasshopperMenu(); / Calling user control page
    stackPanelHome.Visibility = System.Windows.Visibility.Hidden;
    pageTransition1.Visibility = System.Windows.Visibility.Visible;
    pageTransition1.ShowPage(controlpage); 
}

在第一页,有2个图标,1个是FoodKing,1个是Grasshopper,然后他们选择要按下哪个图像,每个图标都有很多按钮并通向其他地方,所以我创建了一个菜单页面以将用户恢复到他们在开始时选择的页面(FoodKing 或 GrassHopper)。但是我该怎么做呢?请参阅我上面的代码。

4

1 回答 1

0
Page currentPage;

private void button12_MouseDown(object sender, MouseButtonEventArgs e) // Back to choose story menu page.
{
    stackPanelHome.Visibility = System.Windows.Visibility.Hidden;
    pageTransition1.Visibility = System.Windows.Visibility.Visible;
    if(currentPage != null)
    {
        pageTransition1.ShowPage(currentPage);
    }
}

private void button2_MouseDown(object sender, MouseButtonEventArgs e) // Food fit for a king.
{
    FoodKing controlpage = new FoodKing(); // Calling user control page          
    stackPanelHome.Visibility = System.Windows.Visibility.Hidden;
    pageTransition1.Visibility = System.Windows.Visibility.Visible;
    pageTransition1.ShowPage(controlpage); 
    currentPage = controlpage;
}

private void button1_MouseDown(object sender, MouseButtonEventArgs e) // Grasshopper
{
    GrasshopperMenu controlpage = new GrasshopperMenu(); // Calling user control page
    stackPanelHome.Visibility = System.Windows.Visibility.Hidden;
    pageTransition1.Visibility = System.Windows.Visibility.Visible;
    pageTransition1.ShowPage(controlpage); 
    currentPage = controlpage;
}
于 2013-07-24T05:55:29.847 回答