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

TreeListView Filters problem

3 Answers 184 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Pepe
Top achievements
Rank 1
Pepe asked on 07 Mar 2011, 12:13 PM

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.

3 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 10 Mar 2011, 11:16 AM
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!
0
Julian
Top achievements
Rank 1
answered on 07 Jun 2011, 03:07 PM
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
0
Julian
Top achievements
Rank 1
answered on 08 Jun 2011, 08:33 AM
Forget about my question, I solve them :)
Tags
TreeListView
Asked by
Pepe
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Julian
Top achievements
Rank 1
Share this question
or