Wrap Text in Label

2 posts, 0 answers
  1. WILLIAM
    WILLIAM avatar
    134 posts
    Member since:
    Jun 2012

    Posted 26 Jul 2013 Link to this post

    Hi Telerik,

    How do I make the text in the Label wrap?  Our users have sentences as questions that go in the label.  How do I make it wrap.  See the attached image.

    Also, I'm specifically setting the MaxWidth of the property grid; yet value column continues to grow.
  2. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 31 Jul 2013 Link to this post

    Hi,

    In order to achieve your goal, you can subscribe to PropertyGrid's FieldLoaded event. Using the ChildrenOfType extension method you can find a TextBlock with name - PART_FieldLabelN and set its TextWrapping property to Wrap. Please check the following code snippet for a reference:
     

    private void propertyGrid_FieldLoaded(object sender, FieldEventArgs e)
            {
                e.Field.ChildrenOfType<TextBlock>().Where(tb => tb.Name == "PART_FieldLabelN").FirstOrDefault().Width = 150;
                e.Field.ChildrenOfType<TextBlock>().Where(tb => tb.Name == "PART_FieldLabelN").FirstOrDefault().TextWrapping = TextWrapping.Wrap;           
            }

    Regards,
    Yoan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
Back to Top