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 8004413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:54:52+00:00 2026-06-04T16:54:52+00:00

I have a class ExpanderItems which gets loaded during runtime and a list of

  • 0

I have a class ExpanderItems which gets loaded during runtime and a list of these is set as the DataContext of a ListBox. Now what I want to do is show the corresponding Images as a Tooltip for each Item. Any suggestions how to do that?

public class ExpanderItem
{
    private String mItemName = "empty";
    public String ItemName
    {
        get { return mItemName; }
        set { mItemName = value; }
    }

    private Image mItemSymbol = null;
    public Image ItemSymbol
    {
        get { return mItemSymbol; }
        set { mItemSymbol = value; }
    }
}

public List<ExpanderItem> getExpanderItems()
    {
        List<ExpanderItem> ItemList = new List<ExpanderItem>();

        ExpanderItem i0 = new ExpanderItem();
        i0.ItemName = "Constant";
        i0.ItemSymbol = new Image();
        BitmapImage bi = new BitmapImage();
        bi.BeginInit();
        bi.UriSource = new Uri(@"/resources/Constant.png", UriKind.RelativeOrAbsolute);
        bi.EndInit();
        i0.ItemSymbol.Source = bi;
        ItemList.Add(i0);
        ...
   }

In the Window where the Items are used I am calling:

   void WindowMain_Loaded(object sender, RoutedEventArgs e)
    {
        lbItems.DataContext = SomeService.getExpanderItems();
    }

XAML Looks like:

   <ListBox x:Name="lstItems" ItemsSource="{Binding}">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <Label Content="{Binding ItemName}">
                </Label>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
  • 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-06-04T16:54:54+00:00Added an answer on June 4, 2026 at 4:54 pm

    Compiled and tested solution.

    XAML:

        <ListBox x:Name="lb"
             ItemsSource="{Binding}"
             HorizontalAlignment="Stretch"
             VerticalAlignment="Stretch">
        <ListBox.ItemContainerStyle>
            <Style TargetType="{x:Type ListBoxItem}">
                <Setter Property="ToolTip">
                    <Setter.Value>
                        <Image Stretch="UniformToFill"
                               Source="{Binding ItemSymbol}" />
                    </Setter.Value>
                </Setter>
            </Style>
        </ListBox.ItemContainerStyle>
        <ListBox.ItemTemplate>
            <DataTemplate>
                <Label Grid.Column="1"
                       Content="{Binding ItemName}">
                </Label>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
    

    Code:

    using System;
    using System.Collections.Generic;
    using System.Windows;
    using System.Windows.Media.Imaging;
    
    namespace Test
    {
        public class ExpanderItem
        {
            private String mItemName = "empty";
            public String ItemName
            {
                get { return mItemName; }
                set { mItemName = value; }
            }
    
            private BitmapImage mItemSymbol = null;
            public BitmapImage ItemSymbol
            {
                get { return mItemSymbol; }
                set { mItemSymbol = value; }
            }
        }
    
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                this.InitializeComponent();
                lb.DataContext = this.getExpanderItems();
            }
    
            public List<ExpanderItem> getExpanderItems()
            {
                List<ExpanderItem> ItemList = new List<ExpanderItem>();
                ExpanderItem i0 = new ExpanderItem
                {
                    ItemName = "Constant",
                    ItemSymbol = new BitmapImage(new Uri(@"/resources/constant.png", UriKind.RelativeOrAbsolute))
                };
                ItemList.Add(i0);
    
                ExpanderItem i1 = new ExpanderItem
                {
                    ItemName = "Constant",
                    ItemSymbol = new BitmapImage(new Uri(@"/resources/constant.png", UriKind.RelativeOrAbsolute))
                };
                ItemList.Add(i1);
    
                return ItemList;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have class A which has ISerializable implemented for custom serialization. Now i need
I have class called GroupSelect and made a collection List(Of GroupSelect)() . Now I
I have class called GroupSelect and made a collection List(Of GroupSelect)() . Now I
I have: class Car {..} class Other{ List<T> GetAll(){..} } I want to do:
I have class in which I am sorting a list. import java.util.*; public class
I have class Zones with properties and i want add data which i read
I have class A, which exposes an event. an object of class B subscribed
I have class A: public B { ...} vector<A*> v; I want to do
I have class A and list of A objects. A has a function f
I have class which implements Countable, ArrayAccess, Iterator and Serializable. I have a public

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.