Category Archives: Silverlight

Redirecting the aspx file from Silverlight


Code for redirecting the ASPX file from Silverlight is as below

string url = “https://nkdeveloper.wordpress.com”;
HtmlPage.Window.Navigate(new Uri(url, UriKind.Absolute), “_blank”);

 

(or)

HtmlPage.Window.Navigate(new Uri(“https://nkdeveloper.wordpress.com “));

(or)

HtmlPage.Window.Eval(“window.open(“https://nkdeveloper.wordpress.com”, ‘_self)”);

 

🙂

How to redirect the XAML file in silverlight


Here is the code to redirect with in silverlight(XAML) file .

public static void Navigate(UserControl newPage)        {

            UserControl oldPage = root.Children[0] as UserControl;

            root.Children.Add(newPage);

            root.Children.Remove(oldPage);

        }

Add the above method in App.xaml file . Then modify the Application_Startup method as below code.

private void Application_Startup(object sender, StartupEventArgs e)        {

            root = new Grid();

            root.Children.Add(new MainPage());

            this.RootVisual =root;

        }

Then you can add the below code line in the page as want for example you can put it inside the button click event

App.Navigate(new MarketCenter());

🙂

%d bloggers like this: