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

ListboxItem with indiv tooltip

3 Answers 225 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
ITA
Top achievements
Rank 1
ITA asked on 08 May 2012, 01:15 PM
Hi,

how do i set an indiv tooltip to a Listboxitem?

Thanks
Regards
Rene

3 Answers, 1 is accepted

Sort by
1
Yana
Telerik team
answered on 14 May 2012, 09:33 AM
Hello Rene,

You can use the same approach as for the regular ListBox, for example if RadListBox is databound:

<telerik:RadListBox  Width="300" x:Name="bindedListBox"
                ItemsSource="{Binding Customers}"              
                ItemTemplate="{StaticResource ListBoxCustomTemplate}"
                />

and add the following DataTemplate:

<DataTemplate x:Key="ListBoxCustomTemplate">
    <TextBlock Text="{Binding Path=Name}" ToolTipService.ToolTip="{Binding Path=Name}"/>
</DataTemplate>

Hope this helps.

Greetings,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
ITA
Top achievements
Rank 1
answered on 15 May 2012, 08:33 AM
Hi,

thanks but in my tooltip ist not the name, there is "System.Windows.Data.Template".

<ListBox Name="KontakteLBX" SelectionMode="Single" ItemContainerStyle="{StaticResource WishlistItemStyle}"  BorderBrush="{x:Null}" Background="Transparent"
         Margin="0,10,0,0" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ToolTip="{StaticResource ListBoxToolTipTemplate}">
 
<ListBox.ItemTemplate>
  <DataTemplate>
    <Border HorizontalAlignment="Center" Style="{StaticResource ListItemBorder}"  Width="Binding ElementName=KontakteLBX, Path=ActualWidth, Converter={StaticResource widthConverter}}"
            VerticalAlignment="Center" x:Name="yahoo">
      <Border.Background>
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
          <GradientStop Color="#FFEFEFEF" Offset="0" />
          <GradientStop Color="#FFE2DFDF" Offset="0.747" />
        </LinearGradientBrush>
      </Border.Background>
      <Grid Name="KontaktItemInner">
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="30" />
          <ColumnDefinition />
         </Grid.ColumnDefinitions>
         <Canvas Grid.Column="0">
           <Ellipse Canvas.Top="-1.2" Canvas.Left="2" Height="20" Width="20" StrokeThickness="1" Stroke="#FFD4D4D4">
             <Ellipse.Fill>
               <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                 <GradientStop Color="#FFD8D8D8" Offset="0.407" />
                 <GradientStop Color="#FFEFEFEF" Offset="1" />                                                       
               </LinearGradientBrush>
             </Ellipse.Fill>
           </Ellipse>
           <Ellipse Canvas.Top="2.5" Canvas.Left="5.7" Height="12" Width="12" StrokeThickness="1" Stroke="#0f7295" Fill="{Binding Farbe}" />
         </Canvas>
         <TextBlock Text="{Binding Name}" FontFamily="Calibri" FontSize="14" VerticalAlignment="Top" Foreground="Black" Grid.Column="1" />   
       </Grid>                                                                       
     </Border>                              
  </DataTemplate>                             
<ListBox.ItemTemplate>
 
/ListBox>

ListBoxToolTipTemplate:
<DataTemplate x:Key="ListBoxToolTipTemplate">
  <TextBlock Text="{Binding Path=Name}" ToolTipService.ToolTip="{Binding Path=Name}"  />
</DataTemplate>


What's wrong here?
Thanks
Rene
0
Georgi
Telerik team
answered on 19 May 2012, 10:15 AM
Hello Rene,

I have modified the project setting the tooltip like this :

<Grid Name="KontaktItemInner" ToolTipService.ToolTip="{Binding FullName}" >

In this case it will appear every time you hover the Grid. If you want the tooltip to appear only when you hover the TextBlock  you can set it like this:

<TextBlock Text="{Binding Name}" ToolTipService.ToolTip="{Binding FullName}" FontFamily="Calibri" FontSize="14" VerticalAlignment="Top" Foreground="Black" Grid.Column="1"  />

You can find attached a simple project implementing the first scenario.
Hope it will help.

Kind regards,
Georgi
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
ListBox
Asked by
ITA
Top achievements
Rank 1
Answers by
Yana
Telerik team
ITA
Top achievements
Rank 1
Georgi
Telerik team
Share this question
or