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

ArgumentExcepetion was thrown on "HierarchyConverter": Cannot register duplicate Name 'HierarchyConverter' in this scope.

1 Answer 90 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ivan
Top achievements
Rank 1
Ivan asked on 07 Mar 2012, 01:37 PM

I cam accross a strange error

I am using this piece of xaml

<Border Grid.Column="5" Grid.Row="0" Grid.RowSpan="6" HorizontalAlignment="Stretch" MinWidth="300" Style="{StaticResource LeftBorderStyle}" Margin="0,10,0,0">
   <ribbon:DropShadow  ShadowSize="15">
     <telerikNavigation:RadTreeView ItemsSource="{Binding TreeItems,Converter={StaticResource HierarchyConverter}}"
                 ItemTemplate="{StaticResource TreeTemplate}"
                 SelectedItem="{Binding SelectedTreeViewItem,Mode=TwoWay}"
                 ExpanderStyle="{StaticResource ExpanderStyle}"
                 Background="White"/>
   </ribbon:DropShadow>
</Border>

and everything worked fine until I added another radtreeview with the same Hierarchy converter then i got the message mention in the title. I fixed it by registrating the converter twice

<converter:HierarchyConverter x:Name="HierarchyConverter"/>
<converter:HierarchyConverter x:Name="HierarchyConverter2"/>

and referencing one from one treeview and the other from the other treeview

the converter looks like this

namespace Converters
{
    using System;
    using System.Collections.ObjectModel;
    using System.Globalization;
    using System.Windows.Data;
    using CoreServiceReference;
 
    public class HierarchyConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Item item = value as Item;
            if (item != null)
            {
                return item.Children;
            }
 
            ObservableCollection<Item> items = value as ObservableCollection<Item>;
            if (items != null)
            {
                return items;
            }
            return null;
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}

As I have fixed this problem this is not that of a issue for me but I still wanted to let you know about this.

1 Answer, 1 is accepted

Sort by
0
Accepted
Petar Mladenov
Telerik team
answered on 12 Mar 2012, 08:28 AM
Hi Ivan,

 I am not able to reproduce such issue neither in SL 4, nor in SL5 project. Could you please check out my test solution and let me know if I am missing something.

Regards,
Petar Mladenov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
TreeView
Asked by
Ivan
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or