Hello,
I'm currently using a XamDataTree and I would like the following functionality:
When there isn't enough space for the text in the XamDataTree I would like the text in the labels to wrap (multiple lines).
Is this possible and how can I achieve this? I've attached an example project.
You can use the ItemTemplate property of the NodeLayout to a DataTemplate which contains a TextBlock with a set width and the TextWrapping property set to Wrap:
<ig:NodeLayout Key="ChildLayout" TargetTypeName="Product" >
<ig:NodeLayout.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Data.ProductName}" TextWrapping="Wrap" Width="90"/>
</DataTemplate>
</ig:NodeLayout.ItemTemplate>
</ig:NodeLayout>
Let me know if you have any questions.
Sincerely,
Valerie
Developer Support Supervisor - XAML
Infragistics
www.infragistics.com/support
Your solution works perfectly when I implement it in a separate project. I used a ValueConverter and a binding to the width of the texblock so the wrapping depends on the width of the XamDataTree. Now I'm trying to integrate it within the 'real' project.
The XamDataTree is now contained in a Grid --> UserControl --> ContentControl --> ContentPane --> SplitPane --> XamDockManager.
At this point setting the width of the textblock doesn't change anything (the textblock keeps a standard size) nor does the binding. The SizeChanged event is activated on the XamDataTree though, so It seems that the containers of the XamDataTree don't have an effect.
I updated my sample to include the structure you described and was unable to reproduce your issue. In the sample the text block size is dependent on the Actual Width of the tree as well as the indentation, etc. The text block resizes as the tree resizes.
Please see modified sample.
If the sample does not help resolve your issue, it would be best if you could provide an example which demonstrates your exact issue so that I can be of further assistance.
Your sample does have the issue that I have. I think I haven't explained it properly. The text does wrap for the childeren of the root layout, but not for the parents. In my project there is only one level in the tree at the moment (the upper level) and this doesn't wrap.
Thanks for your help!
I am still unsure what the issue is. I added the ItemTemplate to the top level of the tree and increased the length of the Category Names. After theses changes, the top level also wraps when the tree is resized. I also tested binding to the Categories collection so that there were no children and again the behavior was the same. I am attaching the updated sample.
Please provide me with the exact steps to reproduce or a short video along with the exact version / build number of NetAdvantage your are running so that I may be of further assistance.
I attached a sample that shows exactly what my problem is as it is much closer to what the code in the real project. It seems that the parent items don't follow the DataTemplate (background was set to red to make this visual).
Thanks for your support!
The nodes in the tree are actually being created with a type of MenuItemType.
You should update the TargetType of the GlobalNodeLayouts to MenuItemType. This will cause the ItemTemplate to be picked up by the parent and the child nodes.
I also updated the Converter to use reflection to get the Level of the node so that this can be used to determine the current indentation and set the width accordingly.