Recommended

  • Silverlight 4 Podcast Pack with Tim Heuer
  • Building Modular Silverlight Applications
  • Prism -  10 Things to Know
  • Securing Silverlight Application and WCF Service using ASP.Net Authentication Techniques
  • Model– View – ViewModel in Silverlight
Skip Navigation LinksHome / Tips / View Tip

Tip: There is no Label control in Silverlight, what should I use instead?

+ Add to SilverlightShow Favorites
4 comments   /   posted by Denislav Savkov on Sep 04, 2008
(0 votes)
Categories: Controls and UI

Yes, that is right, there is no Label control in Silverlight. Instead you should use the new control System.Windows.Controls.TextBlock. Keep in mind that it can display only text, no images or other type of content, just text.

Xaml

<TextBlock x:Name="statusText" Text="Active" TextWrapping="Wrap" TextAlignment="Left" VerticalAlignment="Center"/>

C#

TextBlock statusText = new TextBlock();
statusText.Text = "Active";
statusText.TextWrapping = TextWrapping.Wrap;
statusText.TextAlignment = TextAlignment.Left;
statusText.VerticalAlignment = VerticalAlignment.Center;

That's it!

 

Share


Comments

Comments RSS RSS
  • RE: Tip: There is no Label control in Silverlight, what should I use instead?  

    posted by anon on Nov 07, 2008 16:46

    how is this a label??

    isnt this just a textblock with the word Active??

  • RE: Tip: There is no Label control in Silverlight, what should I use instead?  

    posted by iiordanov on Nov 10, 2008 02:09

    Hi anon,

    Yes this is just a textblock with the word Active in it, but there is no other control that is closer to the standard label control.
    However the release of the Silverlight Control Toolkit contains control named Label and it can be used instead of the TextBlock. You can find more information about the Silverlight Control Toolkit here.

  • RE: Tip: There is no Label control in Silverlight, what should I use instead?  

    posted by andy on Sep 21, 2009 20:34
    What property keeps the user from typing in it?
  • RE: Tip: There is no Label control in Silverlight, what should I use instead?  

    posted by andy on Sep 21, 2009 21:36
    What property keeps the user from typing in it?

Add Comment

 
 

   
  
  
   
Please add 1 and 4 and type the answer here: