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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:49:29+00:00 2026-05-30T09:49:29+00:00

I have a List<Employee> . Each Employee has a byte[] storing a picture (or

  • 0

I have a List<Employee>. Each Employee has a byte[] storing a picture (or null). I need to somehow bind this byte array to an image control on a content template I’m using, or if the Employee doesn’t have a picture I want to display a local jpg file. The way I’ve come up with is to define a converter that will return either the BitmapImage (return type from GetImageFromByteArray() method) or a string (the path of the filename). This obviously means that this method is capable of returning two types, but I wouldn’t have thought this was a problem seeing as though I’ve specified the return type as object.

Anyway, here’s my C#:

public class GuidToImageConverter : IValueConverter
        {
            public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                Guid id = new Guid(value.ToString());
                Employee employee = Employees.SingleOrDefault(o => o.Id.Equals(id));
                return employee.Picture != null ? GetImageFromByteArray(employee.Picture) : "/Resource/images/silhouette.jpg";
            }

            public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                throw new NotSupportedException();
            }
    }

And used in the XAML like so:

    <local:GuidToImageConverter x:Key="GuidToImageConverter"/>

    <local:OrientedGroupHeaderContentTemplateSelector x:Key="GroupHeaderContentTemplateSelector">
        <!-- Default templates: -->
        <local:OrientedGroupHeaderContentTemplateSelector.HorizontalMonthViewDateTemplate>
            <DataTemplate>
                <Image Width="60" Height="60" Margin="5 0 10 0" HorizontalAlignment="Left" Stretch="UniformToFill" Source="{Binding Path=Name.Id, Converter={StaticResource GuidToImageConverter}, ConverterParameter=1}" />
            </DataTemplate>
        </local:OrientedGroupHeaderContentTemplateSelector.HorizontalMonthViewDateTemplate>
    </local:OrientedGroupHeaderContentTemplateSelector>

The error:

“Error 1 – Type of conditional expression cannot be determined because there is no implicit conversion between ‘System.Windows.Media.Imaging.BitmapImage’ and ‘string'”

I understand that this would probably not be an issue if a proper MVVM structure was in place but it’s not feasible at the moment to change it all.

  • 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-30T09:49:30+00:00Added an answer on May 30, 2026 at 9:49 am

    Change the return statement to this to make it work:

    if(employee.Picture != null)
        return GetImageFromByteArray(employee.Picture)
    return "/Resource/images/silhouette.jpg";
    

    Or you could first create an image from the ‘default image’ and then you can use the return statement as before.

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

Sidebar

Related Questions

I have two array list. Each has list of Objects of type Employee. The
I have two array list. Each has list of Objects of type Employee. The
I have a Collection of Employees. Each employee has a ID. This ID number
I got an Employee class and each employee has a list of applied leaves.
I have a site where employees can login and manage things. Each employee has
I have a simple data structure Employee Employee has List Education has University, Department
I have a table of employees. Each employee has a manager, and each manager
I have a SharePoint list with 5 options (questions). Each option has a dropdown
Lets say you have an employee table and a jobs list table. Each employee
I have a database of employees and their direct manager. Each employee row has

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.