Displaying tooltip for a checkbox on a treeview

6 posts, 0 answers
  1. Ruth
    Ruth avatar
    16 posts
    Member since:
    Nov 2011

    Posted 28 Feb 2012 Link to this post

    Is there a way to display a tool tip when user is hovering around the checkbox on a treeview?
  2. Rahul
    Rahul avatar
    118 posts
    Member since:
    Feb 2011

    Posted 29 Feb 2012 Link to this post

    Hi Ruth,

                Please check out below code to apply tooltip for checkbox in tree view.

    <Grid x:Name="LayoutRoot">
           <Grid.Resources>
               <DataTemplate x:Key="Team">
                   <StackPanel Orientation="Horizontal">
                       <CheckBox Click="CheckBox_Click" ToolTipService.ToolTip="Check Me"/>
                   <TextBlock Text="{Binding Name}" />
                   </StackPanel>
               </DataTemplate>
                
               <telerik:HierarchicalDataTemplate x:Key="Division" ItemTemplate="{StaticResource Team}"
              ItemsSource="{Binding Teams}">
                   <TextBlock Text="{Binding Name}" />
               </telerik:HierarchicalDataTemplate>
                
               <telerik:HierarchicalDataTemplate x:Key="League" ItemTemplate="{StaticResource Division}"
              ItemsSource="{Binding Divisions}">
                   <TextBlock Text="{Binding Name}" />
               </telerik:HierarchicalDataTemplate>
                
           </Grid.Resources>
           <telerik:RadTreeView Name="radTreeView"  ItemTemplate="{StaticResource League}">
                
           </telerik:RadTreeView>
       </Grid>


    Thanks & Regards
    Rahul
  3. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2967 posts

    Posted 02 Mar 2012 Link to this post

    Hi Rahul,

     We are glad to know that you have found a way to achieve this functionality. In the attached project you can find another approach - the default template of the RadTreeViewItem is extracted from Blend and the same Tooltip  is applied in the ChechBoxElement:

    <CheckBox ToolTipService.ToolTip="Check Me"
                              x:Name="CheckBoxElement" Grid.Column="2"
                              IsTabStop="False" Margin="5,0,0,0"
                              telerik:StyleManager.Theme="{StaticResource Theme}
                        " Visibility="Collapsed"
                              VerticalAlignment="Center"/>
     

    All the best,
    Petar Mladenov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  4. Ruth
    Ruth avatar
    16 posts
    Member since:
    Nov 2011

    Posted 05 Mar 2012 Link to this post

    Rahul and Petar,

    Thank you for your code samples.

    Rahul - I need to see a tool tip when user is hovering over the checkbox without actually clicking it.

    Petar - I am trying not to have a checkbox in a data template. I would prefer to utilize
    IsTriStateMode="True" IsOptionElementsEnabled="True" ItemsOptionListType="CheckList" 
    to display a checkbox on a treeview. Is it still possible to display a tool tip for a checkbox?
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2967 posts

    Posted 06 Mar 2012 Link to this post

    Hello Ruth ,

     So I guess the project I attached is just what you need. Please note that I have used the default TriState Behavior and I have not included CheckBox in the ItemsTemplate:

    <Grid.Resources>
              <telerik:HierarchicalDataTemplate x:Key="itemtemplate" ItemsSource="{Binding Children}" >
                  <TextBlock Text="{Binding Name}" />
              </telerik:HierarchicalDataTemplate>
          </Grid.Resources>
     
          <telerik:RadTreeView x:Name="tree"
                               IsExpandOnSingleClickEnabled="false"
                               IsLineEnabled="True"
                               IsOptionElementsEnabled="True"
                               IsTriStateMode="True" ItemTemplate="{StaticResource itemtemplate}" />
    Do not hesitate to ask if  you need further assistance.

    Greetings,
    Petar Mladenov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  6. Ruth
    Ruth avatar
    16 posts
    Member since:
    Nov 2011

    Posted 06 Mar 2012 Link to this post

    Thank you, Petar!
Back to Top