Multibinding in RadTreeView

3 posts, 0 answers
  1. Claudio
    Claudio avatar
    9 posts
    Member since:
    Feb 2009

    Posted 15 Oct 2010 Link to this post

    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. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 20 Oct 2010 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Claudio
    Claudio avatar
    9 posts
    Member since:
    Feb 2009

    Posted 20 Oct 2010 Link to this post

    THX a lot.
    IT WORKS GREAT !!!

Back to Top