我是Windows8开发的新手。为了我在大学的最后一年项目,我必须创建一个Windows8手机应用程序-我正在处理应用程序的我的主页,我已经在MainPage.xaml中设置为全景页
我想知道如何使用PanoramaControl.DefaultItem属性从一个全景项移动到另一个全景项,只需单击一个按钮。
我有一个“主页”全景项目与导航按钮,我想导航到其他全景项目在同一页面内。我设置的一个全景项目是一个叫做“我的建议”的项目。
例如,用户选择位于“主页”全景项目中的“我的建议”按钮,则应用程序将转到该特定全景项目,即“我的日记”
以下是我到目前为止为在MainPage.xaml中设置全景项目而创建的代码-
<!--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
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));
}如果有任何信息丢失或有什么不合理的地方,请告诉我。提前感谢
发布于 2014-01-03 20:13:16
你需要在每个按钮上放一个名字,双击它们来创建方法,然后使用NavigationService.Navigate(新的Uri等)将你带到你想要的页面(PanoramaPage2,例如)
发布于 2014-03-12 16:59:00
如果要导航到第二个项目:
private void My Advice_Click(object sender, EventArgs e)
{
ParanomaPageName.SelectedIndex = 1;
}如果您想导航到第三项:
private void My Advice_Click(object sender, EventArgs e)
{
ParanomaPageName.SelectedIndex = 2;
}诸若此类。
发布于 2014-11-18 06:17:21
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);
}https://stackoverflow.com/questions/20405470
复制相似问题