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

Treeview with custom Hierarchical Template and checkbox

1 Answer 109 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Michele
Top achievements
Rank 2
Michele asked on 06 Sep 2010, 12:16 PM
Hello,
I've got a treeview with a custom hierarchical template ... I need to add a checkbox to it, with the treestate... how can I do this without having to specify the treeview checkbox behavior manually??

consider the following class

[DataContract]
  public class ListaContainer
  {
      [DataMember]
      public string NomeLista { get; set; }
      [DataMember]
      public List<Banca> Banca { get; set; }
      //[DataMember]
  }
 
  [DataContract]
  public class Level1
  {
      [DataMember]
      public string Descrizione { get; set; }
 
      [DataMember]
      public List<Level2> Level2s { get; set; }
  }
 
  [DataContract]
  public class Level2
  {
      [DataMember]
      public string Descrizione { get; set; }
 
      [DataMember]
      public List<Level3> Level3s { get; set; }
  }
 
  [DataContract]
  public class Level3
  {
      [DataMember]
      public string Descrizione { get; set; }
 
      [DataMember]
      public List<Level4> Level4s{ get; set; }
  }
 
  [DataContract]
  public class Level4
  {
      [DataMember]
      public string Descrizione { get; set; }
 
      [DataMember]
      public List<Level5> Level5s { get; set; }
  }
 
  [DataContract]
  public class Level5
  {
      [DataMember]
      public int IDInterno { get; set; }
 
      [DataMember]
      public string Descrizione { get; set; }
 
  }

The level 1-4 template are defined so :

<telerik:HierarchicalDataTemplate x:Key="Level2" ItemsSource="{Binding Level3s}">
                  <StackPanel Orientation="Horizontal" Height="16">
                       
                      <Image Source="{Binding Converter={StaticResource Imageconverter},ConverterParameter=Level2}" Height="16" Width="16"  Margin=" 0,0,6,0" />
                      <TextBlock Text="{Binding Descrizione}"/>
                  </StackPanel>
              </telerik:HierarchicalDataTemplate>


While the Level 5 is :

<DataTemplate x:Key="xxx">
                   <StackPanel Orientation="Horizontal" Height="16">
                       <Image Source="{Binding Converter={StaticResource Imageconverter},ConverterParameter=xxx}" Height="16" Width="16" Margin=" 0,0,6,0" />
                       <!--<TextBlock Text="{Binding Descrizione}"/>-->
                       <HyperlinkButton Content="{Binding Descrizione}" Tag="{Binding IDInterno}" Click="HyperlinkButton_Click"></HyperlinkButton>
                   </StackPanel>
               </DataTemplate>

Thanks
Paolo

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 07 Sep 2010, 03:21 PM
Hello Paolo,

You can take advantage of the build in check box support of RadTreeVeiw. Setting the IsOptionElementsEnabled to true will add checkbox component in front of every item in the tree. Setting the IsTriStateMode to true will enable the tri-state mode behavior.

You can take a look at the following help article for more info: http://www.telerik.com/help/silverlight/radtreeview-features-checkbox-support.html#Tri-state_Check_Boxes

Best wishes,
Hristo Milyakov
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
Tags
TreeView
Asked by
Michele
Top achievements
Rank 2
Answers by
Hristo
Telerik team
Share this question
or