(X) Hide this
    • Login
    • Join
      • Generate New Image
        By clicking 'Register' you accept the terms of use .

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

(2 votes)
Denislav Savkov
>
Denislav Savkov
Joined Feb 11, 2008
Articles:   14
Comments:   6
More Articles
8 comments   /   posted on Sep 04, 2008
Categories:   Controls

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!

 


Subscribe

Comments

  • -_-

    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??

  • iiordanov

    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?
  • -_-

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


    posted by TcD on Jun 05, 2010 14:19

    Dudes, It's very easy to do this!))

    There's a control like ContentPresenter.. use it :p smth like:

    ContentPresenter label = new ContentPresenter();
    label.Content = "The text you wanna show";

     or in XAML:

    <ContentPresenter x:Name="label" Content="The text you wanna show" />

     if I help you I will be thanks for a little sum of money even if it will be 1 dollar.

    you can thanks me with webmoney system WMZ: Z209580240366

    Good luck,

    TcD

  • -_-

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


    posted by TcD on Jun 05, 2010 15:48

    Dudes, It's very easy to do this!))

    There's a control like ContentPresenter.. use it :p smth like:

    ContentPresenter label = new ContentPresenter();
    label.Content = "The text you wanna show";

     or in XAML:

    <ContentPresenter x:Name="label" Content="The text you wanna show" />

     if I help you I will be thanks for a little sum of money even if it will be 1 dollar.

    you can thanks me with webmoney system WMZ: Z209580240366

    Good luck,

    TcD

  • -_-

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


    posted by carmo on Jan 06, 2011 16:48

    Namespace:
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"

    Code for xaml:
    <sdk:Label FontWeight="Bold" FontFamily="Calibri" Content="Your Text" />

     

    for example...

  • -_-

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


    posted by priya on Feb 24, 2011 09:19
    Its available in silverlight toolkit. Jst download and install

Add Comment

Login to comment:
  *      *