locked
Sketchflow Prototype Refresh RRS feed

  • Question

  • If I have multiple animations in a single screen, and at the end of each one I have a dialog for the user to refresh the page to play other animations or move to a different screen, how do I refresh the page without having to click on the Silverlight menu on the left

     

    Thanks

    -m

    Wednesday, March 24, 2010 12:17 PM

All replies

  • You can create your own behavior (or use the same code in an event handler) to refresh the current screen.  Please note that this is not a public API, and may change without warning in future versions. To use the behavior version, attach the behavior to the object you want to trigger the refresh, select it, and add a trigger in the properties panel, probably an eventtrigger.  Set the event to click, or whatever you want to have trigger the action.

    The code you would use in a code behind event handler to refresh the current screen:

    Microsoft.Expression.Prototyping.Services.PlayerContext.Instance.ActiveNavigationViewModel.RefreshCurrentScreen();
    

    A behavior version:

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Shapes;
    using System.Windows.Interactivity;
    using Microsoft.Expression.Interactivity.Core;
    
    namespace SilverlightPrototype34Screens
    {
    	public class Behavior1 : Behavior<DependencyObject>
    	{
    		public Behavior1()
    		{
    			// Insert code required on object creation below this point.
    
    			//
    			// The line of code below sets up the relationship between the command and the function
    			// to call. Uncomment the below line and add a reference to Microsoft.Expression.Interactions
    			// if you choose to use the commented out version of MyFunction and MyCommand instead of
    			// creating your own implementation.
    			//
    			// The documentation will provide you with an example of a simple command implementation
    			// you can use instead of using ActionCommand and referencing the Interactions assembly.
    			//
    			this.MyCommand = new ActionCommand(this.MyFunction);
    		}
    
    		protected override void OnAttached()
    		{
    			base.OnAttached();
    
    			// Insert code that you would want run when the Behavior is attached to an object.
    		}
    
    		protected override void OnDetaching()
    		{
    			base.OnDetaching();
    
    			// Insert code that you would want run when the Behavior is removed from an object.
    		}
    
    		
    		public ICommand MyCommand
    		{
    			get;
    			private set;
    		}
    		 
    		private void MyFunction()
    		{
    			Microsoft.Expression.Prototyping.Services.PlayerContext.Instance.ActiveNavigationViewModel.RefreshCurrentScreen();
    		}
    		
    	}
    }

    Wednesday, March 24, 2010 12:58 PM
    Moderator
  • Thank You
    Wednesday, March 24, 2010 1:06 PM