This morning I felt like recreating in Silverlight 2, with Microsoft Blend 2.5 March Preview, a little executable I made in WPF. First of all I listened to some lying-in-a-caribbean-beach-sipping-pineapple-and-grenadine-juice music to tame the frustration without having to drink any alcohol.

Back to the subject. I couldn't manage to make a message appear and disappear at the click of an object because the Visibility option "Hidden" is not available. The solution turned out to be very simple. It is actually a color animation. The initial color of the font is the same as the background. Then in the animation I changed the color to Black for 2 seconds. At 02:01:00 I added a keyframe to turn the text back to its original color. Here is the result:

This animation creates the illusion of a message appearing after being triggered by clicking a button and then disappearing. Notice the fading effect achieved by the 0.1" color animation at the end.

Update 2008 Aug 2: The app doesn't work properly because of an Event Handler issue. Will post solution in the future.

Update 2008 Sep 3: The solution is in my post Fix for: Make text appear and disappear.

Update 2008 Oct 15: The text properties are not found in type "button": in this case TextWrapping ="Wrap" and TextAlignment ="Center". I had to make the button longer so the text would fit. I also added the FontSize property because the default size was too big.

Currently rated 3.3 by 3 people

  • Currently 3.333333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Related posts

Comments

Sean Blakemore gb

Saturday, March 22, 2008 4:26 AM

Looks nice! A better way might be to animate the Opacity of the TextBlock though. That way you can have the same effect without being dependant on the background, you might switch out the colour, maybe put an image or even a video as the background and it'd still work..

Admin us

Saturday, March 22, 2008 4:39 AM

Thanks Sean,
playing with the opacity of the text was a first choice, but for some reason the xaml wouldn't take the changes. I thought it was a Blend bug. Now I feel like getting back to it and give the opacity another try.
Cheers.

timheuer us

Saturday, March 22, 2008 7:39 AM

try visibility 'collapsed' -- which is the equivalent of hidden

Admin us

Saturday, March 22, 2008 8:12 AM

I tried that as well before coming up with the color animation solution, which by the way doesn't represent much work at all. I worked in parallel with Blend 2.5 March Preview and Visual Studio 2008. After losing the battle against Opacity, Collapsed and the likes I decided to go around the problem. Nevertheless I shall revise the issue.
Thanks a bunch Tim!

sirrocco ro

Saturday, March 22, 2008 4:33 PM

Weird that it doesnt' work in Silverlight ... such a simple thing. In WPF works right away - with Visibility.Hidden.

Admin us

Saturday, March 22, 2008 6:25 PM

I KNOOOOW! Frown But I guess that's how it is with a web framework. It's supposed to be LIGHT so a lot of features are missing and may never be available. Still, I like Silverlight a lot.

ariel.newsblogdirect.com

Sunday, April 13, 2008 11:45 AM

Pingback from ariel.newsblogdirect.com

hidden object

Silverlight Girl

Tuesday, July 08, 2008 7:09 AM

Useless in SL2B2, fixes soon to come (me go to bed now)

Comments are closed