Microsoft® Expression Blend is an excellent tool for developing rich Windows®-based applications and user interfaces (UIs) that can interact with user input. For example, if you want your application to start an animation timeline that moves a ball when a user moves the mouse, Expression Blend has features that you can use to configure that relationship. You can also configure your application to respond to changes in the application state itself.
There are two methods that you can use in Expression Blend to make your application respond to user input and application changes:
- Triggers. You configure triggers under
Triggers in the Interaction panel. You do not need
to know how to program or write XAML code to configure triggers.
You can use a trigger to start, stop, pause, resume, remove, or skip to the end of an animation timeline when the user interacts with the objects in your application, or when the states of those objects change. You can also set triggers on state changes to change property values (such as background color). You do not need to use code to configure triggers—you can do everything in Design view in Expression Blend. For more information, see Triggers and Animation in this User Guide.
- Event handlers. You set up event handlers in the
panel. (In the Properties panel, click the Events
You can use event handlers to run a procedure that involves more than setting a property or controlling an animation timeline. For example, you can add other programming logic such as setting a property on another object, loading a new document, creating a new object, using a mathematical calculation to animate an object, and so on. Event handler methods are defined in the code-behind file of your document, and written in C# or Visual Basic® .NET. For example, if your document is named Window1.xaml, the event handlers are contained in the Window1.xaml.cs or Window1.xaml.vb file, depending on the programming language that you use.
For a list of events that you can hook up to, either by using triggers or by using event handler methods, see Events quick reference in this User Guide.
Expression Blend helps you to write event handler methods, by generating the code for empty methods. If you have Microsoft® Visual Studio® 2005 Standard Edition or later installed, Expression Blend will open your project in Visual Studio 2005, will open the code-behind file, and then will paste in the empty event handler method. If you do not have Visual Studio 2005 Standard Edition or later installed, Expression Blend will copy the empty event handler method to the Clipboard so that you can manually open the code-behind file and paste the method in. For more information, see Create a new event handler method in this User Guide.
Expression Blend was designed with team development in mind. Often, software teams are made up of designers who work on the UI and programmers who work on the code that runs behind the UI. You might receive an altered code-behind file from a developer who has added various event handler methods for you to hook into from the UI. You can do this in Expression Blend. For more information, see Hook up an existing event handler method.
Experience with programming Windows-based applications is useful when you are writing event handlers. This is because of the Windows Presentation Foundation (WPF) threading model and the timing of UI rendering. For example, if you create an event handler method that updates the text that is displayed in a Label, performs some other calculations, and then updates the text in the same Label again before the event handler method completes, you will only see the last update. This is because the rendering of your UI occurs at the end of your event handler method and all processing is done on the same thread, so your application cannot take time out during the execution of your method to update the UI. For information about how to write WPF applications that have multiple UI updates and calculations, see the Threading Model topic in the WPF section of MSDN.