TreeListView Filters problem

4 posts, 0 answers
  1. Pepe
    Pepe avatar
    1 posts
    Member since:
    Mar 2011

    Posted 07 Mar 2011 Link to this post

    Hello  the filters doesn’t appears when I bind a TreeListView to a specific model, the approach of the model is similar as this:

    public class A
        {
            private static readonly ObservableCollection<A> _children = new ObservableCollection<A>();

            public static ObservableCollection<A> Children
            {
                get { return _children; }
            }
        }

    public class B : A
        {
            public string Name { get; set; }

            public string Type { get; set; }

            public virtual void LoadChildren()
            {
                // add some A items
                for (int i = 0; i < 10; i++)
                {
                    Children.Add(new B{Name = i.ToString(),Type = "string"});
                }
            }
        }

     public class C : B
        {
            public override void LoadChildren()
            {
                // add some C items
                for (int i = 0; i < 10; i++)
                {
                    Children.Add(new C { Name = i.ToString(), Type = "string" });
                }
            }
        }

    MainWindow.xaml:

    <telerik:RadTreeListView x:Name="tv">
                                    <telerik:RadTreeListView.ChildTableDefinitions>
                                        <telerik:TreeListViewTableDefinition ItemsSource="{Binding Children}" />
                                    </telerik:RadTreeListView.ChildTableDefinitions>

                                    <telerik:RadTreeListView.Columns>
                                        <telerik:GridViewDataColumn Width="*" 
                                                                DataMemberBinding="{Binding Name}"
                                                                Header="Name"/>

                                        <telerik:GridViewDataColumn Width="Auto" 
                                                                MinWidth="150"
                                                                DataMemberBinding="{Binding Type}"
                                                                Header="Type"
                                                                HeaderTextAlignment="Center" />

                                    </telerik:RadTreeListView.Columns>
                                </telerik:RadTreeListView>

    Mainwindow.cs

      private void Window_Loaded(object sender, RoutedEventArgs e)

     {

                var b = new B();

                b.LoadChildren();

                var c = new C();

                c.LoadChildren();

              

                tv.ItemsSource = A.Children;

    }

    Thanks in advance.

  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 10 Mar 2011 Link to this post

    Hello Pepe,

    This inheritance architectures implies that you are using heterogeneous data as ItemsSource of your RadTreeListView. Since RadTreeListView is meant to work properly with homogeneous data only, I wouldn't advise you to use it for this very case. You may try to implement this scenario, utilizing a hierarchical RadGridView.


    Greetings,
    Ivan Ivanov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. UI for WPF is Visual Studio 2017 Ready
  4. Julian
    Julian avatar
    77 posts
    Member since:
    Dec 2010

    Posted 07 Jun 2011 Link to this post

    Ok, I have the same issue.

    My class structure is the following one:

    public interface IYamlItem
    {
    }

    public abstract class YamlItemBase: IYamlItem
    {
    }

    public class YamlItem: YamlItemBase
    {
    }

    and I also have collection of YamlItem:

    public class YamlItems : ObservableCollection<YamlItem>
    {
     public YamlItems (){}

     public YamlItems (List<YamlItem> newSource) : base (newSource)
     {
     }
    }

    what I'm doing wrong ?

    Thank you in advance,
    Julian
  5. Julian
    Julian avatar
    77 posts
    Member since:
    Dec 2010

    Posted 08 Jun 2011 Link to this post

    Forget about my question, I solve them :)
Back to Top