请教VB.net里.xaml页面之间跳转方法

zhabu 2010-04-14 09:13:27
那位朋友知道Silverlight中怎么样在两个.xaml页面之间跳转。
这两天一直在查资料但是都是C#的程序没有VB的!
...全文
126 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
jv9 2010-04-14
  • 打赏
  • 举报
回复
VB和C#是一样的只是语法不同。

在App.xaml中

Dim pager As New PageNavigator()
Me.RootVisual = pager
Navigator.pager = pager
Navigator.Switch(New Login())



PageNavigator.xaml.vb

Partial Public Class PageNavigator
Inherits UserControl

Public Sub New
InitializeComponent()
End Sub

Public Sub Navigate(ByVal nextPage As UserControl)
Me.Content = nextPage
End Sub

Public Sub Navigate(ByVal nextPage As UserControl, ByVal state As Object)
Me.Content = nextPage
Dim nav As INavigator = TryCast(nextPage, INavigator)
If nav IsNot Nothing Then
nav.UtilizeState(state)
Else
Throw New ArgumentException("nextPage cannot be found! " & nextPage.Name.ToString())
End If
End Sub
End Class


Navigator.vb


Public NotInheritable Class Navigator

Public Shared pager As PageNavigator

Private Sub New()
End Sub

Public Shared Sub Switch(ByVal newPage As UserControl)
pager.Navigate(newPage)
End Sub

Public Shared Sub Switch(ByVal newPage As UserControl, ByVal state As Object)
pager.Navigate(newPage, state)
End Sub

End Class





INavigator.vb

Public Interface INavigator
Sub UtilizeState(ByVal state As Object)
End Interface



详细参考这里:
http://silverlightchina.net/html/tips/2010/0119/600.html

http://silverlightchina.net/html/tips/2010/0317/856.html

8,744

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧