Silverlight的页面默认是没有上下或左右滑动条的,所以你可能会碰到这种情况,做好了一个Silverlight页面却无法浏览到底部的内容(完整的内容)。所以,我们需要在程序启动前,就把所有的页面都装在一个ScrollVIEwer里就可以了!
第一个步骤 ,在App.xaml里实现如下代码:
可能为了以后的方面,我们还需要在外层套一层GrID,所以代码变成:
private static GrID grIDRoot;
private static ScrollVIEwer root;
public App()
{
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
InitializeComponent();
}
private voID Application_Startup(object sender,StartupEventArgs e)
{
grIDRoot = new GrID();
root = new ScrollVIEwer();
root.Content = new MainPage();
grIDRoot.Children.Add(root);
this.RootVisual = grIDRoot;
}
public static voID Navigate(UserControl newPage)
{
root = new ScrollVIEwer();
root.Content = newPage;
grIDRoot.Children.Clear();
grIDRoot.Children.Add(root);
}
程序启动后,会先加载MainPage.xaml
这时候,你就发现MainPage里已经有滑动条了
如果要在MainPage里导航到其他页面,那么使用下面的代码就可以了:
App app = (App)Application.Current;
Page2 ep = new Page2 ();
App.Navigate(ep);
以上是内存溢出为你收集整理的如何给Silverlight页面添加滑动条全部内容,希望文章能够帮你解决如何给Silverlight页面添加滑动条所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)