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

2 posts, 1 answers
  1. Ivan
    Ivan avatar
    13 posts
    Member since:
    Aug 2011

    Posted 07 Mar 2012 Link to this post

    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}"

    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.

  2. Answer
    Petar Mladenov
    Petar Mladenov avatar
    3147 posts

    Posted 12 Mar 2012 Link to this post

    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.

    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 >>
Back to Top