[英]Navigating between xaml pages using Hyperlink NavigateUri in windows 8 application
In Windows phone 8 application, it is possible to navigate between XAML pages using the hyperlink as shown below 在Windows Phone 8应用程序中,可以使用超链接在XAML页面之间导航,如下所示
Hyperlink MyLink = new Hyperlink();
MyLink.NavigateUri = new Uri("/Views/SamplePage.xaml?entryId=" + entryId, UriKind.Relative);
I am creating dynamic hyperlinks inside IValueConverter based on the content. 我正在基于内容在IValueConverter中创建动态超链接。 I am porting the application to Windows 8 and i could not use the same code, as windows 8 supports only the navigation using the Frame
我将应用程序移植到Windows 8,我无法使用相同的代码,因为Windows 8仅支持使用Frame导航
this.Frame.Navigate(typeof(SamplePage)); this.Frame.Navigate(typeof运算(的SamplePage));
Is there any other way, i can use Hyperlinks to navigate between xaml pages in Windows 8 metro applications. 有没有其他方法,我可以使用超链接在Windows 8 metro应用程序中的xaml页面之间导航。
Or is there any way to get the current Frame from within IValueConverter to navigate between the pages? 或者有没有办法让IValueConverter中的当前Frame在页面之间导航?
Sounds like you are navigating in the ValueConverter- I personally would not do that. 听起来像是在ValueConverter中导航 - 我个人不会这样做。
Use the Frame object, create your own abstraction as a service, or use behaviors (which you of course can use converters with) 使用Frame对象,创建自己的抽象作为服务,或使用行为(您当然可以使用转换器)
<Grid x:Name="grid5" Grid.Row="1" Grid.Column="2" Background="Purple">
<TextBlock x:Name="TextBox" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="45" Text="Navigation with param" Margin="0,165,3,165"/>
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Tapped">
<core:NavigateToPageAction TargetPage="Behaviors_And_Triggers.NewPage" Parameter="{Binding ElementName=TextBox,Path=Text}"/>
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</Grid>
Dont forget to add the Behaviors SDK extension (Add Reference => Extensions => Behaviors) and namespace: 别忘了添加Behaviors SDK扩展(Add Reference => Extensions => Behaviors)和命名空间:
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
Note: Behaviors_And_Triggers. 注意:Behaviors_And_Triggers。 NewPage => NewPage is the name of the page!
NewPage => NewPage是页面的名称!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.