I was wondered about the variety of effects in Blend 4 for Silverlight developers and am going to talk about it over a series of articles. First in this series would be the ripple effect, which helps you to create a fluid like surface. And of, course you need Expression Blend 4 to do this.
First things first, open a Blend 4 application and select a new Silverlight Project In this sample application; I had used this effect on an image control. What it primarily does is give a fluid like effect on the control to which it is applied.
Here is the objects used in my application
Just add a reference to the Microsoft.Expression.Effects.dll present in %windir%\Program Files\Microsoft SDKs\Expression\Blend\Silverlight\v4.0\Libraries folder.
Now select the image and click on effects. You will see an additional option of effects there, like
Expand the Namespace and select Ripple Effect from that. You will get 4 options like this.
I played with this and found out that Frequency, Magnitude and Phase talks about the waves that are formed as ripples. It was interesting to play with that and make it zero finally.
Now create a storyboard which begins like,
Note that we had we had set the values zero in normal scenario and we are setting it in beginning of storyboard. And in the end make it zero again. Like,
Now we are all set. In mouse down event handler of image, put the code like,
private void image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Point p=e.GetPosition(image);
p.X /= 175 ;
p.Y /= 175 ;
ImgRipple.Center=p;
sbRipple.Begin();
}
Now run the application and voila, it just is liquid.
I had attached the source code and hope you enjoy this.