问题
I have a hub with 5 positions, and i just want to put a button and when i click,go to Specifically position... In Pivot control i can use SelectedItems with Index Position but here... I don't know
<Grid x:Name="MainFragment" >
<Hub x:Name="hubMain" Header="Você no mundo, o mundo em você!" Margin="1,0,0,0">
<HubSection x:Name="HubOne" Header="A Faculdade dos Guararapes">
<DataTemplate>
<Grid>
<Border CornerRadius="50" Background="White" Opacity="0.5" >
</Border>
<Image Source="/Assets/Fg.png" Width="100" HorizontalAlignment="Center" VerticalAlignment="Top"></Image>
<TextBlock Text="A Faculdade dos Guararapes tem por finalidade desenvolver processos de formação de nível superior, envolvendo o ensino, a pesquisa e a extensão, a prestação de serviços à comunidade, a investigação e a difusão da cultura, da ciência, da tecnologia e das artes." TextWrapping="Wrap" Foreground="White" FontSize="20" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,125,0,0" />
<Border HorizontalAlignment="Center" VerticalAlignment="Bottom" CornerRadius="50" Width="364" Height="150" Margin="11,0" >
<Border.Background>
<ImageBrush Stretch="Fill" ImageSource="Assets/apresentacao.png"/>
</Border.Background>
</Border>
</Grid>
</DataTemplate>
</HubSection>
回答1:
.ScrollToSection(HubSectionName)
is the key, my friend. If you name for both hub and hub sections then on click of the button following should work for you.
private void MyBtnClick(object sender, RoutedEventArgs e)
{
hubMain.ScrollToSection(HubOne);
}
However, I wouldn't suggest you to navigate like that, as it would defeat the purpose of Hub template.
来源:https://stackoverflow.com/questions/30091659/how-to-navigate-to-specifically-hub-position-windows-phone-8-1