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

Multibinding in RadTreeView

2 Answers 96 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Claudio
Top achievements
Rank 1
Claudio asked on 15 Oct 2010, 09:48 AM
Hi, i've got a problem.
in my project i've a class like this :

 

 

 

 

public class Progetto
   {
       public Progetto()
       {
           ID = 0;
           Descrizione = String.Empty;
           Stringhe = new ObservableCollection<Stringa>();
           Sprites = new ObservableCollection<Sprite>();
       }
       public int ID { set; get; }
       public String Descrizione { set; get; }
       public ObservableCollection<Stringa> Stringhe { set; get; }
       public ObservableCollection<Sprite> Sprites { set; get; }
   }

In my RadTree i'd like to see  under the root node (Progetto) the two items "stringhe" and "sprites". I Tried with HierarchicalDataTemplate but with no result because under the root node i can only see "Stringhe" or "Sprites"... how to see that together ?? :

 

 

 here my Hierrarchical..

<HierarchicalDataTemplate x:Key="Stringa">
             
           <StackPanel Orientation="Horizontal">
               <TextBlock Text="{Binding Ciao}" Foreground="Black" FontWeight="Bold" FontSize="12" />
               <TextBlock Text="{Binding Descrizione}" Foreground="Black" FontWeight="Bold" FontSize="12" />
           </StackPanel>
       </HierarchicalDataTemplate>
       <HierarchicalDataTemplate x:Key="Sprite">
           <StackPanel Orientation="Horizontal">
               <TextBlock Text="{Binding ID}" Foreground="Black" FontWeight="Bold" FontSize="12" />
               <TextBlock Text="{Binding Descrizione}" Foreground="Black" FontWeight="Bold" FontSize="12" />
           </StackPanel>
       </HierarchicalDataTemplate>
 <HierarchicalDataTemplate x:Key="Progetti" ItemsSource="{Binding Stringhe}"
                                 ItemTemplate="{StaticResource Stringa}">
           <StackPanel Orientation="Horizontal" >
               <TextBlock Text="{Binding ID}" Foreground="Black" FontWeight="Bold" FontSize="12" />
               <TextBlock Text="{Binding Descrizione}" Foreground="Black" FontWeight="Bold" FontSize="12" />
           </StackPanel>
       </HierarchicalDataTemplate>

Any Idea.. THANX IN ADVANCE

2 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 20 Oct 2010, 03:44 PM
Hello Claudio,

A possible way  to see both your  "Stringa" and "Sprite" items under the "Progetto" is to make them extend a common class . For example your Progretto can have an ObservableCollection<ProgretoItemProgretoItems and this collection will be an union of your collections Stringhe and Sprites (Stringa and Sprite will both extend ProgretoItem). Then you can bind the ItemsSource of the HierarchicalDataTemplate to the ProgretoItems collection.

This will allow you to even define two different DataTemplates for the Stringa and Sprite data items and display different properties. In order to implement this, you will need to define a DataTemplateSelector class and set it as an ItemTemplateSelector in the HierarchicalDataTemplate.

Also you can set an ItemContainerStyleSelector - you will be able to define custom styles for the different  ProgretoItem types.

I prepared a sample project for you illustrating such scenario. Please take a look at it and tell me if it satisfies your needs. I would be be glad if I can further assist you.


Greetings,
Petar Mladenov
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
Claudio
Top achievements
Rank 1
answered on 20 Oct 2010, 03:55 PM
THX a lot.
IT WORKS GREAT !!!

Tags
TreeView
Asked by
Claudio
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Claudio
Top achievements
Rank 1
Share this question
or