Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Silverlight 2 #top of page , page switch
3 replies. Latest Post by HarshBardhan on September 29, 2008.
(0)
BigWyo
Member
1 points
5 Posts
09-25-2008 8:33 PM |
Hola,
How does one switch to the top of a new page in Silverlight? If Page1 has content 1200px(Height) and the switch button is at the bottom of the page; when I switch to Page2 800px(Height) I am still located at the bottom of the browser window when Page 2 loads and can only see half of Page 2's content. I would like to switch to the top of the broswer window during a page switch.
Any help would be greatly appreciated.
Thanks
HarshBar...
Star
9908 points
1,719 Posts
09-26-2008 1:04 AM |
hi,
You Can call a Javascript method from silverlight which will navigate you to top of the Page.
09-29-2008 10:00 AM |
Excellent idea HarshBardhan,
This is one solution to have your web browser go to the top of a page when a new Silverlight page is loaded.
The code I used is simple and goes as follows:
C# nextpage.xaml.cs
using System.Windows.Broswer;
public nextpage()
{ HtmlPage.Window.CreateInstance("topOfPage"); // "topOfPage" is your javascript function name
}
.aspx file where the silverlight .xap file is being used.
<script type="text/javascript" >function topOfPage() { window.scrollTo(0,0)}</script>
Thanks for the ideas.
09-29-2008 10:23 AM |
Hi,
I think this is the only idea by which we can get top of the Browser..