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

  • Home
  • SEARCH
  • 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 6155809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:30:05+00:00 2026-05-23T20:30:05+00:00

i have a question, i have created a ListBoxItem in extression blend, which has

  • 0

i have a question, i have created a ListBoxItem in extression blend, which has a StackPanel and this contains a Image and TextBlock.

the problem is, that i dont know how to set a property to get access to the image and textblock to set it.
i can create new item but how to set the image url and text?

  • 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-23T20:30:06+00:00Added an answer on May 23, 2026 at 8:30 pm

    The XAML needs to bind to the properties in the datasource, and the ItemsSource of the ListBox needs to be set. I include below the xaml and .cs that generates the screen shot shown. I have also included a simple class that contains the data.

            <ListBox x:Name="myItems">
                <ListBox.ItemTemplate>
                    <DataTemplate >
                        <StackPanel Orientation="Horizontal">
                            <Image Source="{Binding image}" Margin="5" />
                            <TextBlock Text="{Binding myName}" VerticalAlignment="Center" />
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
    

    The .cs for the MainPage should include:

    public partial class MainPage : PhoneApplicationPage
    {
        ObservableCollection<dataItem> items;
    
        public MainPage()
        {
            InitializeComponent();
            items = new ObservableCollection<dataItem>();
            addItems();
            this.myItems.ItemsSource = items;
        }
    
        private void addItems()
        {
            items.Add(new dataItem() { myName = "Jason", image = "1.png" });
            items.Add(new dataItem() { myName = "Joanne", image = "2.png" });
        }
    }
    

    My data object is called dataItem and looks like so:

    public class dataItem : INotifyPropertyChanged
    {
    
        private string _name = "";
        public string myName
        {
            get
            {
                return _name;
            }
            set
            {
                if (value != _name)
                {
                    _name = value;
                    NotifyPropertyChanged("myName");
                }
            }
        }
    
        private string _image = "";
        public string image
        {
            get
            {
                return _image;
            }
            set
            {
                if (_image != value)
                    _image = value;
                NotifyPropertyChanged("image");
            }
        }
    
        public event PropertyChangedEventHandler PropertyChanged;
        public void NotifyPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
    

    I have implemented INotifyPropertyChanged to ensure that the UI is updated as new items are added to the datasource (dataItem). The images need to be added as content and should be Copy Always to ensure they are on the device. The finished app looks like:

    Phone screen grab

    I hope this helps.

    Jason.

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

Sidebar

Related Questions

The scenario that created this question: We have a package that is a dependency
I have one question. I created a variable which contains the concatenated variable, e.g
I have a follow-up question to this one . I created a new form,
I have a question on the java applet.I've created a java applet,which is a
I have a question regarding image alignment with CSS. For example I have created
i have a question about mod_rewrite. this is my static html site architecture created
For another question I have created some XML related code that works on my
I have a question which can be divided into two subquestions. I have created
I have question concerning a function I created. I would like to show the
I have a question regarding an update function I created... CREATE OR REPLACE FUNCTION

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.