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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:30:13+00:00 2026-05-31T10:30:13+00:00

I am creating a User Interface in WPF and I need to have an

  • 0

I am creating a User Interface in WPF and I need to have an image control in the View that changes to a specific image depending on the value returned from the ViewModel. For my particular case is just a traffic light so it can be red, yellow or green and depending on this value the corresponding image must be loaded.

so in the View I have the next image control…

<Image Source="{Binding Path=ServerStatus, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" HorizontalAlignment="Left" Width="41" Height="34"/>

The ViewModel on the other hand has this code…

    //...

     // The status of the server represented as a traffic light
    public enum m_Enumeration_ServerStatus { Red, Yellow, Green };

    private m_Enumeration_ServerStatus p_ServerStatus;

    //...

    /// <summary>
    /// The status of the server represented as a traffic light
    /// Red: stopped
    /// yellow: starting
    /// Green: Started
    /// </summary>
    public m_Enumeration_ServerStatus ServerStatus
    {
        get { return p_ServerStatus; }

        set
        {
            base.RaisePropertyChangingEvent("ServerStatus");
            p_ServerStatus = value;
            base.RaisePropertyChangedEvent("ServerStatus");
        }
    }

So the View will be “informed” of the PropertyChange.

What code do I need to add in order to load the corresponding image for the setted property value?

  • 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-31T10:30:15+00:00Added an answer on May 31, 2026 at 10:30 am

    what about a datatemplate for you enum types? in your datatemplate you can set your right image.

    <DataTemplate DataType="{x:Type local:m_Enumeration_ServerStatus}">
    <TextBlock x:Name="valueText"/>
    <DataTemplate.Triggers>
        <DataTrigger Binding="{Binding}" Value="{x:Static local:m_Enumeration_ServerStatus.Red}">
            <Setter TargetName="valueText" Property="Text" Value="First Value" />
        </DataTrigger>
    </DataTemplate.Triggers>
    <DataTemplate.Triggers>
        <DataTrigger Binding="{Binding}" Value="{x:Static local:m_Enumeration_ServerStatus.Red}}">
            <Setter TargetName="valueText" Property="Text" Value="Second Value" />
        </DataTrigger>
    </DataTemplate.Triggers>
    </DataTemplate>
    

    instead of textblock you have to set your image of course

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

Sidebar

Related Questions

Given that you're creating a User Control in WPF that will be displayed on
I'm currently creating a user interface using WPF and would like to display a
Greetings! I'm creating a User Control that will display data in a GridView control.
We have a designer creating a user interface for an application. The main window
I'm creating a user approval interface leveraging the .Net Membership class. I have a
I have a problem with a WPF control that I'm trying to host in
I am interested in creating a WPF user interface for a QT project. I
I'm creating a WPF MVVM application. I have a long process that I want
I'm creating an application that uses curses to build a simple user interface. It
I'm creating an iOS user interface with a lot of different UIImageViews that will

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.