Click here to Skip to main content
Click here to Skip to main content

Create Custom Speech Bubbles in Silverlight.

By , 11 Jan 2011
 

Introduction

We all know what Speech Bubbles are. They are typically used in Comic Books and have appeared in many RIAs.

So how do you create them in a Silverlight Application? More importantly, how do you do this without adding external .dlls?

2 Possible Solutions Requiring External .DLLs

Right off the bat, I know at least two ways to create the speech bubbles that look just like the ones in comic books.

  • Using the Callout Shapes included with Blend 4.
  • Using the free 3rd party control named FreeBubbles (I used this before Blend 4).

Unfortunately, we cannot use either of these as they will both add extra .dlls to the project and they are not as customizable as some people might want.

So Why Wouldn't You Want to Use One of Those Solutions?

I can think of a few reasons:

  1. You do not want to increase the size of your .XAP by including extra .dlls.
  2. You do not have Expression Blend or the license to use the .dlls.
  3. You want a custom Speech Bubble that is not included in the four “Callout” Controls with Blend.

Instead of using one of these methods, we will create a Speech Bubble in Blend 4 using Path element and a TextBlock.

A Look at the Callout Shapes Included with Blend 4

Before we get started, let's look at the Callout Shapes included with Blend 4. Using Blend 4, you can simply drag/drop these controls onto your Silverlight application and you are ready to go.

image

We can create all of these Speech Bubbles and even some of the modern bubbles used in recent comic books. Let's get started.

That's Cool and All, But I Want Something More Custom

Start up Expression Blend 4 and select the Pen Tool.

On the Art Board, start connecting the dots like I did below. You can add a color if you wish.

image

…keep going

image

…complete

image

Let’s go ahead and add some text to the Speech Bubble.

Drag a TextBlock from the Panel and put it directly inside the Speech Bubble.

image

Go ahead and set the TextAlignment to Center for the TextBlock. and give it some text.

image

A Custom User Control

At this point, you could go ahead and create a user control if you want to reuse the Speech Bubble you created. Select both the Path and the TextBlock by clicking then while holding down CTRL and then Right Click them.

image

Select Make Into User Control.

image

Give it a name and then Build your project.

image

image

Making a More Traditional Speech Bubble

Let's create another one using the Ellipse for the older comic book style of Speech Bubbles. Drag an Ellipse to the Artboard and give it a color. Now, grab the Pen and drag a triangle like I did below.

image

Simply drag it over a corner of the Ellipse.

image

image

Select Combine, then Unite and you will have a Path.

image

At this point, you can go ahead and add a TextBlock like we did earlier.

image

And Another Speech Bubble

Let's go ahead and create a rounded rectangle one by adding a Rectangle to the Artboard.

image

Go ahead and set the RadiusX and RadiusY to 25 to give it rounded edges.

image

Let’s create another path and drag it right on top of our rounded rectangle like we did earlier.

image

…looking good.

image

image

Select Combine, then Unite and you will have a Path.

image

At this point, you can go ahead and add a TextBlock like we did earlier.

image

The Final Product

So let’s look at what we’ve created today using the path element and TextBlock. As you can tell, it required more work but meets the requirements. This was actually fun to do and I encourage anyone that visits my blog to send in request like this.

image

I Like Your Articles, Where Can I Find More of Them?

If you enjoyed this article, then check out my blog for others like this. You may also want to subscribe to my blog or follow me on Twitter.

alt Subscribe to my feed

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

mbcrump
Software Developer (Senior) Telerik
United States United States
Member
Michael Crump is a Silverlight MVP and MCPD that has been involved with computers in one way or another for as long as he can remember, but started professionally in 2002. After spending years working as a systems administrator/tech support analyst, Michael branched out and started developing internal utilities that automated repetitive tasks and freed up full-time employees. From there, he was offered a job working at McKesson corporation and has been working with some form of .NET and VB/C# since 2003.
 
He has worked at Fortune 500 companies where he gained experience in embedded systems design and software development to systems administration and database programming, and everything in between.
 
His primary focus right now is developing healthcare software solutions using Microsoft .NET technologies. He prefers building infrastructure components, reusable shared libraries and helping companies define, develop and automate process standards and guidelines.
 
You can read his blog at: MichaelCrump.net or follow him on Twitter at @mbcrump.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionHow would you make bubble with dynamic contextmemberVitaliy Markitanov5 Nov '12 - 13:32 
GeneralMy vote of 5memberKenny Woo4 Sep '12 - 5:50 
GeneralMy vote of 5memberChristian Amado27 Jul '12 - 10:56 
GeneralI did something like this for WPF in this articlemvpSacha Barber12 Jan '11 - 2:13 
GeneralMy vote of 5mvpKunal_Chowdhury11 Jan '11 - 15:47 
GeneralMy vote of 5memberSledgeHammer0111 Jan '11 - 9:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 11 Jan 2011
Article Copyright 2011 by mbcrump
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid