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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:46:30+00:00 2026-06-18T08:46:30+00:00

I got a label which triggers this function everytime I press enter private void

  • 0

I got a label which triggers this function everytime I press enter

private void WordInput_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.Key == Key.Enter)
        {
            WordInput.Text = String.Empty;
            Smiley.Source = new BitmapImage(new Uri(@"FailSmile2.png", UriKind.Relative));
        }
    }

Which changes a picture to the one above(FailSmile2.png)
But now, I want to check, if it’s FailSmile2 that is being shown, then I want to change to another picture instead, with the same function. Should I use a cuople of IF to check the source? In that case, how?

Thanks!

  • 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-18T08:46:31+00:00Added an answer on June 18, 2026 at 8:46 am

    Could just store it as a private field on your class:

    private string CurrentImagePath;
    
    private void WordInput_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.Key == Key.Enter)
        {
            WordInput.Text = String.Empty;
    
            if (CurrentImagePath == null)
                CurrentImagePath = @"FailSmile2.png";
            else if (CurrentImagePath == @"FailSmile2.png")
                CurrentImagePath = @"SomeOtherImage.png";
    
            Smiley.Source = new BitmapImage(new Uri(CurrentImagePath, UriKind.Relative));
        }
    }
    

    Not sure about what exactly you want to do. If you plan on cycling through multiple images, it may be better to store those in a List<Uri> and cycle through them one at a time. Essentially, somehow you’ll want to store the current state of your control (likely as a private field) and based on that make changes or possibly wire different events.

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

Sidebar

Related Questions

I've got a NSTimer and a label which shows the seconds counting down. -(void)start
I've got a label in my mxml like this; <s:Label id=lblChange text={_symbol.change>0 ? '+'
If I've got an image which look, for example, like this: 0101001 1101101 0101001
Hey guys, I've got this jQuery code which works in Chrome and Safari but
I've got a remote source which does not return id and value or label.
I've got the code below in my RootViewController (which is a UITableViewController). This code
I've got a label which is displayed in a subview. I got the text
(this follows ggplot2 loess Q for which I got a nice answer) -- leading
I wonder if someone can help me - I've got a label which I
I've got strings which consist of a label, underscores, and an ID: category_4 office_362

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.