SIGN UP MEMBER LOGIN:    
ARTICLE

How to fix a missing Vertical Scrollbar on a Silverlight Page

Posted by Mahesh Chand Articles | Silverlight with C# October 13, 2010
This tip shows how to add scrollbars to a Silverlight page.
Reader Level:

When you create a Silverlight application using Expression Blend 4 or Visual Studio 2010, and run it, there are no scrollbars in the browser and you may not see your complete page.

Here is my website I am building and as you can see, I can't see the scrollbars on the page so basically I am unable to read the page contents.

AtgImg1.jpg

To fix this, we need to add a ScrollViewer or Scrollbars to the page and one of the simplest way to do so is by changing the Application_Startup method in App.xaml.cs file.

The default Application_Startup method looks like following:

private void Application_Startup(object sender, StartupEventArgs e)

{

    this.RootVisual = new MainPage();

}

 

Now what we can do is, implement a ScrollViewer and place the MainPage within it. Here is the code to do so.

private void Application_Startup(object sender, StartupEventArgs e)

{

    ScrollViewer scroller = new ScrollViewer();

    scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;

    scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;

    scroller.Content = new MainPage();

    this.RootVisual = scroller;

}

 

Now if you run the application, you will notice both scrollbars are visible now.

AtgImg2.jpg


Here is an article on ScrollViewer control.

ScrollViewer control in Silverlight 3


Login to add your contents and source code to this article
share this article :
post comment
 
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor