1 导航控件
Frame Control :Frame
3具体使用导航的方法:
@1 直接操作
NavigationService.Navigate(new Uri("/Home", UriKind.Relative));
@2使用控件
<HyperlinkButton Name="HomeLink" Content="home"
NavigateUri="/Home" TargetName="ContentFrame" />
解释:
• Providing the URI to navigate to (NavigateUri) 路径
• Specifying the name of the Frame to navigate within (TargetName)
目标框架可能有多个。可能有多个Frame对象。
@3设定source
Using the Source Property of the Frame Control
ContentFrame.source = new Uri("/Home", UriKind.Relative);
使用这种方式无法使用 前进 后退等功能。
类似asp.net 开发中的页面传值
发出:
/Views/ProductDetailsView.xaml?ProductID=879
接收:
if (NavigationContext.QueryString.ContainsKey(paramName)) int.TryParse(NavigationContext.QueryString[paramName],out paramValue);
但是这样url很不友好,类似MVC,我们又更好的办法:
显示在URL 网址栏上的信息
ProductDetails/879
只要设定
<Navigation:UriMapping Uri="/{pageName}/{ID}"
MappedUri="/Views/{pageName}.xaml?ProductID={ID}"/>
实际解析时候的路径
/Views/{pageName}.xaml?ProductID=879
具体参见源码。
5整合 浏览器 导航按钮
设定 JournalOwnership 的三个枚举值之一
Automatic(默认) |
如果 Frame 控件是顶级框架,它将与浏览器日记集成在一起;否则,它将维护自己的日记。 |
OwnsJournal |
|
UsesParentJournal |
6 FragmentNavigation 的事件
• Navigating
• Navigated
• NavigationStopped
• NavigationFailed
• FragmentNavigation 在开始导航到内容片段时发生。
7 听说有这么回事
ContentFrame.Navigate(new Uri("ProductDetails/879#StockLevels", UriKind.Relative));
变成
ProductDetails/879$StockLevels
但是我试了好像也没有啊。还是会解析成#~~
8 View Events ( page 类的 方法)
• OnNavigatedTo
• OnNavigatingFrom
• OnNavigatedFrom
• OnFragmentNavigation
|
disabled |
|
|
缓存页面,并且每次访问时都重复利用缓存的实例,而不考虑帧的缓存大小。 |
|
|
Enabled |
缓存页面,但当超过帧的缓存大小时放弃缓存的实例。 |
注意:当你使用required时候,第二次以后的访问都是同一个缓存了的对象,但是8中的
10访问其他类库的页面
url= /CustomerModule;component/Views/CustomerList.xaml
但是我自己尝试的时候报错。。
navigation 的一些属性
|
|
|
获取或设置 ContentControl 依赖项属性的值。 (继承自 ContentControl。) |
||
获取或设置用于显示 ContentControl 内容的数据模板。 (继承自 ContentControl。) |
||
|
|
|
获取或设置框架是否负责管理自己的导航历史记录,或者它是否与 Web 浏览器日记集成。 |
||
|
|
|
|
|
|
一些常用的方法:
参考资料
Silverlight 4 in action
Pro Business Applications with Silverlight 4
MSDN
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。