This is a migrated thread and some comments may be shown as answers.

Wrap Text in Label

1 Answer 121 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
WILLIAM
Top achievements
Rank 1
WILLIAM asked on 26 Jul 2013, 02:59 PM
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.

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 31 Jul 2013, 01:01 PM
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 >>
Tags
PropertyGrid
Asked by
WILLIAM
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or