Sunday, August 8, 2010

Add auto scroll bars to Silverlight app

Without below code, if your user control is bigger than browser's resolution, the scrollbars will not show.

private void Application_Startup(object sender, StartupEventArgs e)
{

ScrollViewer root = new ScrollViewer();
root.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
root.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
root.Content = new MainPage();
this.RootVisual = root;


}