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

[Solved] Easy way to get header text to wrap?

3 Answers 158 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Scott Laughton
Top achievements
Rank 1
Scott Laughton asked on 27 Mar 2009, 01:27 PM
Hi there,
        Is there an easy way to get the HeaderText to Wrap to the width of the TreeView rather than pushing out and adding a scroll bar?

Regards,

    Scott.

3 Answers, 1 is accepted

Sort by
0
Tihomir Petkov
Telerik team
answered on 30 Mar 2009, 12:28 PM
Hi Scott,

You can either (1) substitute the ContentPresenter in the default ControlTemplate of RadTreeViewItem with a TextBox, or (2) assign a HeaderTemplate in which you set a DataTemplate containing a TextBox. In either case you will need to set the TextWrapping property ot the TextBox to true, as well as explicitly set the Width of the TextBox to whatever suits your scenario.

Let me know if this answers your question.

Sincerely yours,
Tihomir Petkov
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Scott Laughton
Top achievements
Rank 1
answered on 30 Mar 2009, 01:32 PM
Tihomir,
Thanks for the reply.  Ok so I did the following:

  1. Created a project in Blend and added the Telerik control references.
  2. Dropped a RadTreeView on the page.
  3. Added Three TreeViewItems, setting the Headers to "Item 1", "Item 2", "Item 3".
  4. Selected the first one and right clicked and chose Edit Control Parts (Template)/Edit A Copy and called it RadTreeViewItemStyle1, saving it in the document not that App.
  5. Replaced the ContentPresenter with a TextBlock and gave it the same name "Header" and it's TextWrap property was set to true.

However when I saved it and went back to the main Page the Header text I had set of "Item 1" was no longer showing in that RadTreeViewItem.  Instead it has the default style text of "TextBlock".  If I edit the Style and Reset this to nothing then nothing shows for the items with this style applied, even when the Header property of the RadTreeViewItem is set.

How can I assign the value to the TextBlock that I replaced the Content Presenter to?

Regards,

Scott. 
0
Tihomir Petkov
Telerik team
answered on 30 Mar 2009, 01:41 PM
Hello Scott,

Sorry, I forgot to mention that in the first scenario you will also need to set the Text property of the TextBox like this:

Text="{TemplateBinding Header}"

In the second approach I suggested, the Text property should be set to as follows:

Text="{Binding}"

Let me know if you have further questions.

All the best,
Tihomir Petkov
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
Scott Laughton
Top achievements
Rank 1
Answers by
Tihomir Petkov
Telerik team
Scott Laughton
Top achievements
Rank 1
Share this question
or