Hey,
I would like to implement Infragistic's XamDataTree but I'm having a problem with binding a NodeLayout to a dictionary.
One of my Items in the Hierarchy holds a property of a dictionary, which I'd like to bind the DataTree's Node Layout too. Actually, to be more specific, I only need to bind the NodeLayout to the dictionary's values list.
However, when I try doing that with this markup
<Infragistics:NodeLayout Key="Fields" TargetTypeName="FieldMetaData" DisplayMemberPath="Values.FieldName"/>
I get this error in my debug output when trying to expand its parent node, to see this exact node layout -
"Unable to cast object of type 'System.Collection.Generic.KeyValuePair`2[FieldMetaData]' to type 'System.String'.
I tried many other tricks and variation that unfortunately didn't work. Also, apparently TargetTypeName does nothing in this case since I guess it doesn't recognize the values as "FieldMetaData" type, so only "Keys" actually works.
So I wonder if XamDataTree even supports dictionaries, or if there's anyway to make it work because all I actually need is to bind to the list of Dictionary values.
In Microsoft's regular TreeView It worked, so it will be a bit disappointing if I couldn't make this work with XamDataTree.
Thanks!
Dror.
Hello Dror,
Here is the support ticket number: CAS-64403-MK72NY we have created on your behalf. I am going to link it to development issue: 73766 so that you get automatically update when a Feature Release containing the fix is available for download. You can get the new version from our website’s “My IG”, “My Keys & Downloads” tags: https://ko.infragistics.com/Membership/Default.aspx?panel=Downloads#Downloads
You can also monitor the support ticket’s progress through the “My Support Activity” tag: https://ko.infragistics.com/Membership/MySupport.aspx
Sincerely,
Petar, MCTS
Developer Support Engineer
Infragistics
www.infragistics.com/support
I'll see if I could find a way to manage in the mean time.
So was this resolved? Do the XamDataTrees' nodelayouts support a Dictionary?
Hi,
Excuse me for not updating this thread sooner. This issue has been fixed and included into the 2011 May Service Release and has also been verified as such by DrorCohen in an internal developer support ticket.
Nice Thanks, So how do I do this for a Dictionary<string,string>. What would be the syntax?
I tried this
<ig:NodeLayout Key="MapLayout" TargetTypeName="Dictionary<string,string>" DisplayMemberPath="Key"/>
but it didn't work. Would really appreciate your help here. Thanks.
Hi jlmehta,
I am attaching the sample from the bug that was fixed last year. You can observe the code and see how to use the Dictionary as ItemsSource for XamDataTree. If you have any questions, please feel free to ask!
Regards,
Nikola.
This sample for dictionary binding to xamDataTree is not available anymore , can you please attach any sample code or file for same .
Thank you in advance
Regards
Nkaur
I have reviewed your code and after further investigation it turned out that if you inherit Dictionary<String, String> in another class, for example InheritedDictionary and use that class and place it in the TargetTypeName it would show the keys or the values of the Dictionary according to the DisplayMemeberPath that you want to see. The other thing is that the Key for the NodeLayout that is going to display the nodes from the dictionary should be equal to the name of the property of that dictionary. I hope that helps you!
To the second question, i don't think it is possible to not have nodes that are not visible, because they don't have children, but i need to double check that and confirm that later.
Any suggestions on this?
Thanks..
Thanks for your example Nikola, but I'm afraid thats not what I'm looking for exactly. Here's roughtly the structure of a tree I want.
Object A has a list of Object B.
Object B has a list of Object C.
Object C has a Dictionary<String, String>
I bind the tree to A.List<B> (List of B is Object A)
I want the tree to look something like this
B1---C11---C12------Dictionary key1------Dictionary key1---C13------Dictionary key1B2---C21------Dictionary key1------Dictionary key1---C22
The code I ahve right now is
<ig:XamDataTree ItemsSource="{Binding InnerReport.ReportColumns}"> <ig:XamDataTree.GlobalNodeLayouts> <ig:NodeLayout Key="ColLayout" TargetTypeName="ReportColumn" DisplayMemberPath="DisplayName"/> <ig:NodeLayout Key="DrlDnLayout" TargetTypeName="ReportDrillDown" DisplayMemberPath="ContextMenulabel"> <ig:NodeLayout.CheckBoxSettings> <ig:CheckBoxSettingsOverride CheckBoxVisibility="Visible" /> </ig:NodeLayout.CheckBoxSettings> </ig:NodeLayout> <ig:NodeLayout Key="MapLayout" TargetTypeName="Dictionary<string,string>" DisplayMemberPath="Key"/> </ig:XamDataTree.GlobalNodeLayouts> </ig:XamDataTree>
Also on a related topic, is it possible for the tree to not show Nodes which have no children? So in the Above example, the tree would not show ReportColumn if its List<ReportDrilldown> is empty.Thanks