Monday, May 3, 2010

Launching a URL from an OOB Silverlight Application

So I'm working on this code browser mostly to help me with my fading memory. In the app I want to be able to launch a url. So I do my normal thing and put a line of code that looks like this:

System.Windows.Browser.HtmlPage.Window.Navigate(new Uri(ThisURI), "_blank");

I was agast when I realized that this didn't work, for that matter it didn't even blow... grr... but with a bit of research I found that the hyper link button worked so a ended up making a little class like this:

public class MyHyperLink : HyperlinkButton
public MyHyperLink(string navigateUri)
base.NavigateUri = new Uri(navigateUri);
TargetName = "_blank";

even better the code to make this works looks like this:

MyHyperLink button = new MyHyperLink("some url here...");

1 comment: