Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. How to change image at run-time corresponding time of day (24 hour format)?

How to change image at run-time corresponding time of day (24 hour format)?

Scheduled Pinned Locked Moved WPF
helpquestioncsharpwpftutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LAPEC
    wrote on last edited by
    #1

    Hello everyone I have two images, image1 represent lunch and image2 represents dinner. When I run my application the image1 is displayed on main window. How can I change image1 to image2 corresponding time of day (at run-time)? For instance: lets say from 12:00 to 17:00 I want my image1 to be displayed at main window, and from 17:00 to 23:00 I want to display image2 at main window. could someone please help me solve this problem, Hence: I'm new to WPF... thanks in advance kind regards lapeci

    M 1 Reply Last reply
    0
    • L LAPEC

      Hello everyone I have two images, image1 represent lunch and image2 represents dinner. When I run my application the image1 is displayed on main window. How can I change image1 to image2 corresponding time of day (at run-time)? For instance: lets say from 12:00 to 17:00 I want my image1 to be displayed at main window, and from 17:00 to 23:00 I want to display image2 at main window. could someone please help me solve this problem, Hence: I'm new to WPF... thanks in advance kind regards lapeci

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      Presumably you have a property representing the image to be displayed and bind your xaml to the property. You then need a timer in your code (code behind or ViewModel). In the timers tick event you check the datetime.now and change the image property to the image you want to display.

      Never underestimate the power of human stupidity RAH

      L 1 Reply Last reply
      0
      • M Mycroft Holmes

        Presumably you have a property representing the image to be displayed and bind your xaml to the property. You then need a timer in your code (code behind or ViewModel). In the timers tick event you check the datetime.now and change the image property to the image you want to display.

        Never underestimate the power of human stupidity RAH

        L Offline
        L Offline
        LAPEC
        wrote on last edited by
        #3

        Hello Mycroft Holmes Thanks for replying to my question... Is there any way you can help me with a sample code because I don't have a clue how to do it I'm very new to wpf... thanks in advance. kind regards lapeci

        M 1 Reply Last reply
        0
        • L LAPEC

          Hello Mycroft Holmes Thanks for replying to my question... Is there any way you can help me with a sample code because I don't have a clue how to do it I'm very new to wpf... thanks in advance. kind regards lapeci

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          Sorry, I don't do code, you are going to have to work it out! If you get stuck with something then come back and we will help.

          Never underestimate the power of human stupidity RAH

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups