I am trying to fill the TreeView programatically.
I have two different tree node types so I have derived them from RadTreeViewItem:
ParametersTemplate and ParametersTemplateGroup are domain specific objects (each ParametersTemplateGroup can contain a number of templates (1:N) and any number of other ParametersTemplateGroups (1:N)). Just like a Folder in Windows can contain N files and other folders.
I have a list of nodes (which can be of one of two types mentioned above), and two dictionaries that contain parametersTemplates and parametersTemplateGroups, accessed by ID.
From the two dictionaries and the list of all nodes I am trying to connect them the way they are connected (according to the parent property):
The line with a commend and three asterisks is the line where I get an ArgumentException thrown. "Value does not fall within the expected range.". This happens when the second node is added, not on the first one. I've even tried (as suggested on another threads) to place something like this before the line that throws an exception:
But this didn't solve the problem.
The stack trace at the moment of an exception:
at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
at MS.Internal.XcpImports.MethodPack(IntPtr objectPtr, String methodName, Object[] rawData)
at MS.Internal.XcpImports.Collection_Add[T](PresentationFrameworkCollection`1 collection, Object value)
at System.Windows.PresentationFrameworkCollection`1.AddImpl(Object value)
at System.Windows.Controls.ItemCollection.AddImpl(Object value)
at System.Windows.Controls.ItemCollection.AddInternal(Object value)
at System.Windows.PresentationFrameworkCollection`1.Add(T value)
at MyProject.Models.Domain.Templates.ParameterTemplateEditorTree.ConnectTreeNodes()
at MyProject.Views.TemplateEditor.ParameterTemplateEditorPage.onParametersTemplateLoaded(LoadOperation`1 operation)
at System.ServiceModel.DomainServices.Client.DomainContext.<>c__DisplayClass13`1.<
Load
>b__11(LoadOperation lo)
at System.ServiceModel.DomainServices.Client.LoadOperation.<>c__DisplayClass4`1.<
Create
>b__0(LoadOperation`1 arg)
at System.ServiceModel.DomainServices.Client.LoadOperation`1.InvokeCompleteAction()
at System.ServiceModel.DomainServices.Client.OperationBase.Complete(Object result)
at System.ServiceModel.DomainServices.Client.LoadOperation.Complete(DomainClientResult result)
at System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult)
at System.ServiceModel.DomainServices.Client.DomainContext.<>c__DisplayClass1b.<
Load
>b__17(Object )
I really don't know how to continue. I don't add that node to any other control at any other place...
What does this exception mean in this context and how to solve this problem?
Thanks in advance.