Silverlight应用开发:页面管理、闪屏与资源使用全解析
1. 页面实例创建与根视觉设置
在Silverlight应用开发中,页面实例的创建是一个基础操作。以下代码展示了如何创建页面实例并设置根视觉:
try
{
// Create an instance of the page.
Type type = this.GetType();
Assembly assembly = type.Assembly;
startPage = (UserControl)assembly.CreateInstance(
type.Namespace + "." + startPageName);
}
catch
{
startPage = null;
}
// If no parameter was supplied or the class couldn't be created, use a default.
if (startPage == null) startPage = new MenuPage();
this.RootVisual = startPage;
上述代码首先尝试通过反射创建指定名称的页面实例。若创建失败, startPage 将被置为 null ,此时会使用默认的 MenuPage 作为起始页面,并将其设置为应用的根视觉。
2. 页面切换
当应用加载完成后,直接更改 RootVisu
超级会员免费看
订阅专栏 解锁全文
12

被折叠的 条评论
为什么被折叠?



