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

ArgumentException when placing RadTreeViewItem in EditMode

3 Answers 56 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Paul Brun
Top achievements
Rank 2
Paul Brun asked on 11 Aug 2010, 11:43 PM
I have defined a DataItemTempate for my RadTreeItem in the following manner:

<DataTemplate x:Key="EditTreeViewTemplate">
       <StackPanel Orientation=
"Horizontal">
           <UserControl Content=
"{Binding IconControl}"/>
           <TextBox Text=
"{Binding Rename, Mode=TwoWay}" Margin="5" />
       </StackPanel>
   </DataTemplate>

I pass the EditTreeViewTemplate into the ItemEditTemplate property of the RadTreeView. Both bindings work because a simple format used in my HierarchicalDataTemplate works without a problem. The UserControl hosts a Icon created in Blend and represented in XAML form.

If I remove the UserControl, the edit works without a problem. Keep it in there, IE crashes with a ManagedRunTimeError 4004

Thoughts on getting this to work.

3 Answers, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 12 Aug 2010, 08:41 AM
Hi Paul Brun,

This exception normally comes up when a visual element is placed in the visual tree twice, it is common when visual elements are databound.

The problem here is a bug in Silverlight where a visual element will not be removed from its parent when the binding is removed / reset.

Several suggestions:
- Use a ContentPresenter instead of a UserControl
then:
1. Remove the visual element (IconControl)  from its parent (ContentPresenter) in the properties getter. Be careful not to get the same property from other code.
2. Bind to a non-visual value and use a ValueConverter to create and initialize the control. This may be a good approach since its lazy and the control is not needed most of the time.

Kind regards,
Miroslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Paul Brun
Top achievements
Rank 2
answered on 12 Aug 2010, 03:06 PM
you don't by chance happen to have a quick example that shows what you are talking about, do you? Just trying to piece together a solution that will make this work and this problem is widely reported too...

Paul
0
Tina Stancheva
Telerik team
answered on 17 Aug 2010, 03:17 PM
Hi Paul Brun,

I attached a sample project illustrating how to use a visual element in an ItemEditTemplate. The example demonstrates three different approaches so that you  can choose the best suited for your scenario.

Take a look at it and let us know if you need more info.

Sincerely yours,
Tina Stancheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeView
Asked by
Paul Brun
Top achievements
Rank 2
Answers by
Miroslav
Telerik team
Paul Brun
Top achievements
Rank 2
Tina Stancheva
Telerik team
Share this question
or