Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6622955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:28:24+00:00 2026-05-25T21:28:24+00:00

I would like to set in Silverlight for each item in a ListBox a

  • 0

I would like to set in Silverlight for each item in a ListBox a tooltip with many rows.

In XAML i have a listbox and a button:

<ListBox Height="100" HorizontalAlignment="Left" Margin="24,136,0,0" Name="listBox1" VerticalAlignment="Top" Width="109" ItemsSource="{Binding}">
<Button Content="Add"  Name="button_add" VerticalAlignment="Top" Width="118" Click="add_Click">

in c#

private void button_add_Click(object sender, RoutedEventArgs e)
    {
        ObservableCollection<Person> obs1 = new ObservableCollection<Person>();
        obs1.Add(new Person(){Name="Name1", Age=1});
        obs1.Add(new Person(){Name="Name2", Age=2});
        listBox1.ItemsSource = obs1;
        // This Line of Code MUST NOT BE USED!! listBox1.DisplayMemberPath = "Name";          
    }
public class Person
{
    public String Name { get; set; }
    public int Age { get; set; }

    public override string ToString()
    {
        return Name;
    }
}

I would like to show for each item the Age as my tooltip.

Edit: Ok, this is the Solution for showing only AGE as tooltip. That is one Line/Row.

                <ListBox Height="100" HorizontalAlignment="Left" Margin="24,136,0,0" Name="listBox1" VerticalAlignment="Top" Width="109" ItemsSource="{Binding}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                                <TextBlock Text="{Binding Name}" ToolTipService.ToolTip="{Binding Age}"/>
                            </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>

But what if i want to show a Tooltip with 2 Lines? something like:

 Name: Name1
 Age: 1

Edit: 3 rows, 2 columns. i also added public String Comment { set; get; } to class Person

                    <ListBox Height="100" HorizontalAlignment="Left" Margin="24,136,0,0" Name="listBox1" VerticalAlignment="Top" Width="109" ItemsSource="{Binding}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <ToolTipService.ToolTip>
                                    <ToolTip>
                                        <Grid>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="20"></RowDefinition>
                                                <RowDefinition Height="20"></RowDefinition>
                                                <RowDefinition Height="40"></RowDefinition>
                                            </Grid.RowDefinitions>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="80"/>
                                                <ColumnDefinition Width="250"/>

                                            </Grid.ColumnDefinitions>
                                            <TextBlock Text="Name: " Grid.Row="0" Grid.Column="0" />
                                            <TextBlock Text="{Binding Name}" Grid.Row="0" Grid.Column="1"/>
                                            <TextBlock Text="Age: " Grid.Row="1" Grid.Column="0"/>
                                            <TextBlock Text="{Binding Age}" Grid.Row="1" Grid.Column="1"/>
                                            <TextBlock Text="Comment: " Grid.Row="2" Grid.Column="0"/>
                                            <TextBlock Text="{Binding Comment}" Grid.Row="2" Grid.Column="1" TextWrapping="Wrap" />
                                        </Grid>
                                    </ToolTip>
                                </ToolTipService.ToolTip>
                                <TextBlock Text="{Binding Name}" />
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>

But there is stil a problem. The comment can be short or long, so i would like to make the ROWS/LINES/SPACE for Comment to be variable or else Text is cut off.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:28:25+00:00Added an answer on May 25, 2026 at 9:28 pm

    You can use any controls for tooltip content:

    <ToolTipService.ToolTip>
        <StackPanel Orientation="Vertical">
            <TextBlock Text="{Binding Name}" />
            <TextBlock Text="{Binding Age}" />
        </StackPanel>
    </ToolTipService.ToolTip>
    

    Other possibility would be to use a converter, that returns the Name and Age separated by \r\n.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to use a transparent png file on a silverlight button. In
I'm using Silverlight 4's gridview in my page, and I would like to have
I have some vector graphic files in XAML format and I would like to
What I want: I would like to have a ScrollView in my Silverlight 4
Here is the problem: I have a Silverlight application where we would like to
In my Silverlight project, I would like to make an assembly which contains .xaml
I would like to set the log file name for a log4j and log4net
I would like to set some initial variables (like format compact and the current
I would like to set up some WMV Video Streaming, using Windows 2003's Streaming
I would like to set some vim options in one file in the comments

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.