Introduction
It is a practice when developing applications that we use visibility to show and hide various objects in our application. But sometimes we need to remove the element while the application is running. Just like we add an element when our application is running.
Behaviors
Microsoft Expression Blend makes it possible for designers to create interactive applications and prototypes instead of static art or click-through designs. There are many ways to create interactivity in your application, whether you drag a prepackaged behavior onto an object, configure triggers or write code that will respond to events. The topics in this section describe the various ways to create interactivity in your application.
You can use behaviors to add interactivity to your application without having to write any code. Behaviors are reusable pieces of packaged code that can be dragged onto any object and then fine-tuned by changing their properties. Instead of being limited to controlling storyboards or defining the appearance of controls, you can design the way your application responds to users by using the standard behaviors that come with Expression Blend.
Remove Action Element Behavior
Under the tab of assets you will find behaviors, in that tab you will find a behavior that will be named "Remove Action Element Behavior". This is the very behavior that would help you to remove an instance of an object while the application is running, for the demo I have made a button and a rectangle using a button and this behavior I would remove the rectangle.
Let's dig in.
-
First of all let's place a button and a rectangle.
-
You will find the behavior under the assets tab, in the sub tab of behaviors.
-
Now you just need to do a simple thing. Just drag this behavior and drop it over the button, it will show some of the properties like this.
-
You can choose the type of event and the target name and object. Now I would just provide a target name that is a rectangle so that on my click event the rectangle removes out.
-
The Very last thing here is that to ensure you have set the event name to click or the very event you want to fire.
-
You are all done, now as you click the button it will remove the rectangle from the screen.
Conclusion
Behaviors in Expression Blend are really amazing and easy to use. There is no need to write the code, just drag and drop and you are done. This was the easiest way to remove an element while the app is running. I hope you find this article interesting, Ask questions and provide suggestions in the comments.
Personal Blog: Blend Unleashed.