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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:08:05+00:00 2026-05-18T09:08:05+00:00

I am having issues of having an image change dynamically. Some background info: I

  • 0

I am having issues of having an image change dynamically.

Some background info:
I have a list box that contains elements that can be selected. These items are food categories.
When a user clicks on one of the foods, I would like an image at a different location of the page to change.

My Xaml file contains:

<Image Name="bigImage" Stretch="Fill" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center"/>

So when the user clicks a certain food category that “bigImage” would change:

FoodCollection foods = (FoodCollection)this.FindResource("FoodCategory");
            Food f = foods[foodListBox.SelectedIndex];
            Title_TextBlock.Text = f.Name;
            bigImage = f.MainImage;

In my food class I have a variable called Image m_mainImage:

    public class Food
    {
        ...

        Image m_mainImage = new Image();
        String m_mainImagePath = string.Empty;

        ...

        public string MainImagePath{
            get { return m_mainImagePath; }
            set
            {
                m_mainImagePath = value;
                m_mainImage.BeginInit();
                m_mainImage.Source = new BitmapImage(new Uri(m_mainImagePath, UriKind.RelativeOrAbsolute));
                m_mainImage.EndInit();
                RaisePropertyChanged("MainImage");
                RaisePropertyChanged("MainImagePath");
            }
        }

        public Image MainImage
        {
            get { return m_mainImage; }
        }


        public event PropertyChangedEventHandler PropertyChanged;
        protected void RaisePropertyChanged(string name)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(name));
        }

    }
}

I read somewhere that I had to “resolve” the image, but I was unclear on what that meant.
I thought this would do it:

m_mainImage.BeginInit();
                    m_mainImage.Source = new BitmapImage(new Uri(m_mainImagePath, UriKind.RelativeOrAbsolute));
                    m_mainImage.EndInit();

Sorry I am still new to WPF and C#.
Thanks in advance.

  • 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-18T09:08:05+00:00Added an answer on May 18, 2026 at 9:08 am

    Have you set the DataContext of the window?

    Without this PropertyChanged won’t be initialised, so:

    if (PropertyChanged != null)
        PropertyChanged(this, new PropertyChangedEventArgs(name));
    

    will never fire as PropertyChanged is always null.

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

Sidebar

Related Questions

I am having issues with ie 8 compatibility mode. I have some buttons that
I am having some issues printing out the subarray homemain=>image This is my JSON
I'm having some trouble with a few routines that are using jQuery to dynamically
I'm having some major issues getting a live tile to update its image via
I have been having a small problem that I can't by-pass it, I keep
I am having some issues with these background images I am using for a
I have a div that on hover will change positioning on an image and
I've been making an image uploader and I'm having a couple of issues. Code
Still having issues with this problem. Please help if you can. So I am
Im having issues getting this to work, maybe its not even possible? I have

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.