ListboxItem with indiv tooltip

4 posts, 0 answers
  1. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 08 May 2012 Link to this post

    Hi,

    how do i set an indiv tooltip to a Listboxitem?

    Thanks
    Regards
    Rene
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 14 May 2012 Link to this post

    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 >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 15 May 2012 Link to this post

    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
  5. Georgi
    Admin
    Georgi avatar
    347 posts

    Posted 19 May 2012 Link to this post

    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 >>
Back to Top