silverlight2008. 9. 1. 19:47


 

A close friend is learning Silverlight 2 and asked me a pretty mundane question but the problem with those kinds of questions is to designers some namespaces are not right there, and easy to use (not intuitive). The question was how do I make the page go to a url in silverlight. The answer to that is the following:

System.Windows.Browser.HtmlPage.Window.Navigate(...);

The Navigate method is not very easy to get to for those not familiar with all the namespaces, furthermore navigate is overloaded which means you can call it in three different flavors, they are:

1. System.Windows.Browser.HtmlPage.Window.Navigate( Uri ) which takes a uri and makes it go to a specific url inside the browser windows. An example would be:

System.Windows.Browser.HtmlPage.Window.Navigate(new Uri("http://www.coreysportfolio.com"));

2. System.Windows.Browser.HtmlPage.Window.Navigate( Uri, target) which takes a uri and a string for target... like "_blank". An example would be:

System.Windows.Browser.HtmlPage.Window.Navigate(new Uri("http://www.coreysportfolio.com"), "_blank");

3. System.Windows.Browser.HtmlPage.Window.Navigate(uri, target, targetFeatures) which takes a uri, a string for target and finally a string for target features. Target features is like the url in javascript urls for controlling the toolbar, window size and other things. An example would be:

System.Windows.Browser.HtmlPage.Window.Navigate(new Uri("http://www.coreysportfolio.com"), "_blank", "toolbar=0");

Hope that helps. Check out the other methods inside HtmlPage and Window in intellisence, there are all kinds of hidden gems there.

'silverlight' 카테고리의 다른 글

silverlight RC0 Released!!  (0) 2008.09.27
silverlight messagebox for debuging  (0) 2008.09.26
버튼 만들어주는 사이트  (0) 2008.08.27
시작페이지 바꾸는법  (0) 2008.08.26
애니메이션 blend로 넣는법 플래시랑 비슷  (0) 2008.08.26
Posted by 동동(이재동)