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.
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
0
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.
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,
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.
Thanks for the reply. Ok so I did the following:
- Created a project in Blend and added the Telerik control references.
- Dropped a RadTreeView on the page.
- Added Three TreeViewItems, setting the Headers to "Item 1", "Item 2", "Item 3".
- 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.
- Replaced the ContentPresenter with a TextBlock and gave it the same name "Header" and it's TextWrap property was set to true.
How can I assign the value to the TextBlock that I replaced the Content Presenter to?
Regards,
Scott.
0
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.
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.