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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:16:13+00:00 2026-06-01T02:16:13+00:00

I am a beginner to WPF . I have a data grid for showing

  • 0

I am a beginner to WPF .

I have a data grid for showing messages with column definitions as below . Data grid is bound to a datatable

<my:DataGridTextColumn Binding="{Binding Module}" Header="Module" 
    Width="75" IsReadOnly="True"></my:DataGridTextColumn>
<my:DataGridTextColumn Binding="{Binding Record ID}" Header="RecordID" 
    Width="75" IsReadOnly="True"></my:DataGridTextColumn>
<my:DataGridTextColumn Binding="{Binding ItemName}" 
    Header="Item/Platform/Country Name" Width="175" IsReadOnly="True">  
    </my:DataGridTextColumn>
<my:DataGridTextColumn Binding="{Binding DateReceived}" 
    Header="DateReceived" Width="150" IsReadOnly="True">
    </my:DataGridTextColumn>
<my:DataGridTextColumn Binding="{Binding Comments}" Header="Comments" 
    Width="300" IsReadOnly="True"></my:DataGridTextColumn>

Now I need to add a coulmn with header as “Status” . and content as image . I am binding
“IsRead” column of the datatable to this column such that if the IsRead value is False i need to show image unread.png and if the IsRead value is True i need to show image read.png

How do i do this?

  • 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-01T02:16:15+00:00Added an answer on June 1, 2026 at 2:16 am

    You could create a StatusImage property in the class that holds your binding properties:

    public string StatusImage {
        get 
        {
            if (IsRead)
                return "read.png";
            return "unread.png";
        }
    }
    

    And then bind it to the image for example:

    <Image Source="{Binding StatusImage}"></Image>
    

    Or as in your case that you haven’t got a class. You could choose between a datatrigger:

    <DataGridTemplateColumn>
        <DataGridTemplateColumn.CellTemplate>
            <DataTemplate>
                <Image Name="IsReadImage" Source="read.png"/>
                    <DataTemplate.Triggers>
                        <DataTrigger Binding="{Binding IsRead}" Value="False">
                        <Setter TargetName="IsReadImage" Property="Source" Value="unread.png"/>
                    </DataTrigger>             
                </DataTemplate.Triggers>         
            </DataTemplate>     
        </DataGridTemplateColumn.CellTemplate> 
    </DataGridTemplateColumn>
    

    Or you could use a value converter:

    Class:

    public class IsReadImageConverter : IValueConverter  
    {
        public Image ReadImage { get; set; }
        public Image UnreadImage { get; set; }
    
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (!(value is bool))
            {
                return null;
            }
            bool b = (bool)value;
            if (b)
            {
                return this.ReadImage
            }
            else
            {
                return this.UnreadImage
            }
        }
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
    

    Window Resources:

    <local:IsReadImageConverter ReadImage="Read.png" UnreadImage="Unread.png" x:Key="BoolImageConverter"/>
    

    Then your binding would be:

    ImageSource={Binding Path=IsRead,Converter={StaticResource BoolImageConverter}}"
    

    Should all work.

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

Sidebar

Related Questions

I'm a complete beginner in WPF and have an app that uses StoryBoard to
I am beginner on WPF and need your help. Problem: I have 4 buttons
While learning c# and wpf, i am trying to get grasp of data binding.
I'm a relative beginner with WPF so please bear with me. I have a
I am a beginner at using WPF. I have wrote some xaml code in
I'm a complete beginner at WPF. I've made a usercontrol labeledTextbox that holds a
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
Absolute beginner question: I have a template file index.html that looks like this: ...
I have a datagrid in a WPF populated from a csv file. This is
I am a beginner in using Blend and WPF in general. I created three

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.