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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:19:20+00:00 2026-05-13T08:19:20+00:00

Here’s what I have: private void HeroMouseEnter(object sender, MouseEventArgs e) { //I did things

  • 0

Here’s what I have:

private void HeroMouseEnter(object sender, MouseEventArgs e)
    {            
        //I did things this was because it is easier to maintain code in a sense that is is a generic
        //method made for all of the heroes images.
        ((Image)sender).Source = GetGlowingImage(((Image)sender).Name);            
    }

    private void HeroMouseLeave(object sender, MouseEventArgs e)
    {
        //I did this IF conditional because I want to ask, "If the sender object
        //is the hero selected, then do NOT change the image to normal.
        if (SelectedHero != ((Image)sender).Name)
        {
            //I did things this was because it is easier to maintain code in a sense that is is a generic
            //method made for all of the heroes images.
            ((Image)sender).Source = GetNormalImage(((Image)sender).Name);                             
        }            
    }

    private void HeroMouseClick(object sender, MouseEventArgs e)
    {
        if (!HasSelectedAHeroBefore)
        {
            HasSelectedAHeroBefore = true;
            //Created a generic way to play the announcers voice according to where a user clicked.
            string soundfile = "AnnouncerVoice/" + ((Image)sender).Name + ".mp3";
            soundPlayer.Open(new Uri(soundfile, UriKind.Relative));
            soundPlayer.Play();

            //I call the MouseEnter event in order to have the clicked picture glow and set the Selected bool to true 
            //to keep it highlighted.
            SelectedHero = ((Image)sender).Name; 
        }
        else if (HasSelectedAHeroBefore)
        {
            //Created a generic way to play the announcers voice according to where a user clicked.
            string soundfile = "AnnouncerVoice/" + ((Image)sender).Name + ".mp3";
            soundPlayer.Open(new Uri(soundfile, UriKind.Relative));
            soundPlayer.Play();

            //I call the MouseEnter event in order to have the clicked picture glow and set the Selected bool to true 
            //to keep it highlighted.
            SelectedHero = ((Image)sender).Name;
            PreviousSelectedHero = ((Image)sender).Name;
        }

    }

The cliffnotes of what I want.
When a user moves his mouse around my pictures, I want the pictures to Glow. I achieve this by changing the image to a photoshopped one (with glow) on MouseEnter. On MouseLeave, I switch the pic back to normal.

When a user click, I want the clicked Image to stay with the Glow one I made. All the while when the user moves his mouse I still want them to glow on MouseEnter and deglow on MouseLeave.

Finally, if a user click an image different than the selected one, the clicked picture must stay selected (glowing) like the one before.

I’m so stumped and I’m sure it’s an easy fix, I’m just a bit rusty.

Thanks tremendously for the help. 😀

Edit: Aplogise, I forgot to mention what isn’t working. EVERYTHING words exacty how I want it to, however when I click another image, the previous one stays glowing (like selected), until I enter the mouse on it and leave it.

Edit2: I’ve added something that may work. But I don’t know how to select a Image control by it’s name. Any help?

else if (HasSelectedAHeroBefore)
        {
            //Created a generic way to play the announcers voice according to where a user clicked.
            string soundfile = "AnnouncerVoice/" + ((Image)sender).Name + ".mp3";
            soundPlayer.Open(new Uri(soundfile, UriKind.Relative));
            soundPlayer.Play();

            //I call the MouseEnter event in order to have the clicked picture glow and set the Selected bool to true 
            //to keep it highlighted.
            PreviousSelectedHero = SelectedHero;
            //Here I want to select the Image control by it's Name property. But it says I can't convert string to Image. ANy help?

            GetNormalImage(((Image)PreviousSelectedHero).Name);
            SelectedHero = ((Image)sender).Name;

        }
  • 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-13T08:19:20+00:00Added an answer on May 13, 2026 at 8:19 am

    Could try in HeroMouseClick…

    PreviousSelectedHero = SelectedHero;
    SelectedHero = ((Image)sender).Name;
    

    EDIT2: I’m assuming Xaml that looks something like this:

    <StackPanel Name = "myContainer>
        <Image Name="heroOne" Source="source1.gif" />
        <Image Name="heroTwo" Source="source2.gid" />
    </StackPanel>
    

    Then in the codebehind you can do:

    using System.Linq;  //EDIT - you'll need this for any Linq query
    
    var hero = 
        (from Image i in myContainer.Children
         where i.Name == previousSelectedHero.Name
         select i).Single(); 
         //this selected the Image from the StackPanel "myContainer" using the Images name attribue
         //and assigns it to hero
    
     hero.Source = GetNormalImage(hero.Name); 
    //this should then set the deselected image back to its original source
    

    Where “myContainer” is whatever you’ve got all the images stored in (such as a Stackpanel or grid or even a list of some sort). Given that this hinges on the images being stored in a certain way and that I’ve written it off the top of my head it may or may not be useful. That said it should select the image you want to change, and change it back to the original.

    More Edit2: I’m assuming its the Linq statement that you’re struggling with. here is a link to what Linq is about, and here is a bunch of samples.

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

Sidebar

Ask A Question

Stats

  • Questions 382k
  • Answers 382k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You could setup a background trace that is run automatically… May 14, 2026 at 10:32 pm
  • Editorial Team
    Editorial Team added an answer XPath isn't a transformation tool so you can't use it… May 14, 2026 at 10:32 pm
  • Editorial Team
    Editorial Team added an answer There is no need to do that. You just have… May 14, 2026 at 10:32 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.