locked
Is there an easy way to load web pages from Blend? RRS feed

  • Question

  • I finally got my first Blend project to work, which is an animated welcome screen.  It does its thing in about 6 seconds, and then forwards the user to the regular home page.  Right now I am doing this with a fragment of java script.  This makes me a tad nervous since some people disable both java and meta-refresh, so it would be better to insert an action that I can incorporate into my storyboard with the desired delay.

    I took a look through the behaviors and did not see anything helpful.  I did find this:

    http://expression.microsoft.com/en-us/library/dd185500(Expression.30).aspx

    but it seems a tad too complicated for my present level of skill.  Is there a simple way to load a page from the same folder as the page that calls my Silverlight app (a very slightly tweaked version of the "default.html" that Blend creates).

    Saturday, January 29, 2011 12:44 AM

Answers

  • Howdy,

    If you include System.Windows.Browser you can then navigate away..

    HtmlPage.Window.Navigate(new Uri("http://www.msdn.com"));

    When your animated welcome screen completes, add that line of code to the completed event. Your code behind page would look something like this:

    using System;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    
    
    //NOTE THIS INCLUDE!!
    using System.Windows.Browser;
    
    
    namespace SilverlightApplication
    {
    	public partial class MainPage : UserControl
    	{
    		public MainPage()
    		{
    			// Required to initialize variables
    			InitializeComponent();
          this.Loaded += new RoutedEventHandler(MainPage_Loaded);
          this.WelcomeScreen.Completed += new EventHandler(WelcomeScreen_Completed);
    		}
    
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
          this.WelcomeScreen.Begin();
        }
    
        void WelcomeScreen_Completed(object sender, EventArgs e)
        {
          HtmlPage.Window.Navigate(new Uri("http://www.msdn.com"));
        }
    	}
    }
    

     

    HTH

    Cheers


    Expression MVP

    my blog : http://x-coders.com/blogs/sneaky/default.aspx

    Saturday, January 29, 2011 1:01 PM
    Moderator

All replies

  • Howdy,

    If you include System.Windows.Browser you can then navigate away..

    HtmlPage.Window.Navigate(new Uri("http://www.msdn.com"));

    When your animated welcome screen completes, add that line of code to the completed event. Your code behind page would look something like this:

    using System;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    
    
    //NOTE THIS INCLUDE!!
    using System.Windows.Browser;
    
    
    namespace SilverlightApplication
    {
    	public partial class MainPage : UserControl
    	{
    		public MainPage()
    		{
    			// Required to initialize variables
    			InitializeComponent();
          this.Loaded += new RoutedEventHandler(MainPage_Loaded);
          this.WelcomeScreen.Completed += new EventHandler(WelcomeScreen_Completed);
    		}
    
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
          this.WelcomeScreen.Begin();
        }
    
        void WelcomeScreen_Completed(object sender, EventArgs e)
        {
          HtmlPage.Window.Navigate(new Uri("http://www.msdn.com"));
        }
    	}
    }
    

     

    HTH

    Cheers


    Expression MVP

    my blog : http://x-coders.com/blogs/sneaky/default.aspx

    Saturday, January 29, 2011 1:01 PM
    Moderator
  • Very, very helpful. 

    It took me a while to figure out which lines I needed to add (and which were already in the default.html created by Blend) and the fact that I had to edit the a few of the names to match my name, but it all works brilliantly.

    I am really starting to like Blend / Silverlight.  Powerful stuff once you figure out how to get all the pieces to work together.  Many thanks for this!

    Sunday, January 30, 2011 4:12 PM