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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:40:35+00:00 2026-05-14T02:40:35+00:00

I have a enum let’s say enum MyEnum { FirstImage, SecondImage, ThirdImage, FourthImage };

  • 0

I have a enum let’s say

enum MyEnum
{
  FirstImage,
  SecondImage,
  ThirdImage,
  FourthImage
};

I have binded this Enum to my combobox in XAML.

While defining an combobox I have defined an ItemTemplate of combox to take Two UI element:

  1. TextBlock that show the enum value (Description)
  2. Image

I have done this much in XAML.

I am wondering where I can specify the Image corrosponding to each item of Enum value in a combobox? Is that possible through data trigger ?

I really appreciate if anyone have the XAML for this scenario.

Many Thanks in advance

  • 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-14T02:40:35+00:00Added an answer on May 14, 2026 at 2:40 am

    You can use a DataTrigger, but would be more maintainable if you used a Converter. Here’s a sample that uses a DataTrigger for a view of the image and text by itself, and then the same DataTrigger to display the image and text in ListBox and ComboBox, and finally, a ListBox and ComboBox that use a Converter to display the image and text:

    XAML

    <Window x:Class="WpfSandbox.EnumToImage.EnumToImage"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:System="clr-namespace:System;assembly=mscorlib"
            xmlns:local="clr-namespace:WpfSandbox.EnumToImage"
            Title="Enum To Image" SizeToContent="WidthAndHeight"  >
    
        <Window.DataContext>
            <local:ImageViewModel x:Name="Model" />
        </Window.DataContext>
    
        <Window.Resources>
    
            <ObjectDataProvider x:Key="EnumDataProvider" 
                                MethodName="GetValues" 
                                ObjectType="{x:Type System:Enum}">
                <ObjectDataProvider.MethodParameters>
                    <x:Type TypeName="local:Decade"/>
                </ObjectDataProvider.MethodParameters>
            </ObjectDataProvider>
    
            <local:DecadeEnumImageConverter x:Key="ImageConverter" />
    
    
            <ControlTemplate x:Key="ImageTemplate" >
    
                <StackPanel Orientation="Horizontal">
                    <Image x:Name="MyImage" Width="64" Height="32" />
                    <TextBlock Text="{Binding}" VerticalAlignment="Center"  />
                </StackPanel>
    
    
                <ControlTemplate.Triggers>
                    <DataTrigger Binding="{Binding}" Value="Ninties" >
                        <DataTrigger.Setters>
                            <Setter TargetName="MyImage" 
                                    Property="Source" 
                                    Value="/EnumToImage/images/90s.jpg"/>
                        </DataTrigger.Setters>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding}" Value="Eighties" >
                        <DataTrigger.Setters>
                            <Setter TargetName="MyImage" 
                                    Property="Source" 
                                    Value="/EnumToImage/images/80s.jpg"/>
                        </DataTrigger.Setters>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding}" Value="Seventies" >
                        <DataTrigger.Setters>
                            <Setter TargetName="MyImage" 
                                    Property="Source" 
                                    Value="/EnumToImage/images/70s.jpg"/>
                        </DataTrigger.Setters>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding}" Value="Sixties" >
                        <DataTrigger.Setters>
                            <Setter TargetName="MyImage" 
                                    Property="Source" 
                                    Value="/EnumToImage/images/60s.jpg"/>
                        </DataTrigger.Setters>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding}" Value="Fifties" >
                        <DataTrigger.Setters>
                            <Setter TargetName="MyImage" 
                                    Property="Source" 
                                    Value="/EnumToImage/images/50s.jpg"/>
                        </DataTrigger.Setters>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding}" Value="Forties" >
                        <DataTrigger.Setters>
                            <Setter TargetName="MyImage" 
                                    Property="Source" 
                                    Value="/EnumToImage/images/40s.jpg"/>
                        </DataTrigger.Setters>
                    </DataTrigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
    
            <DataTemplate x:Key="ItemsTemplateWithConverter">
                <StackPanel Orientation="Horizontal">
                    <Image Width="64" Height="32"  
                           Source="{Binding Converter={StaticResource ImageConverter}}"/>
                    <TextBlock Text="{Binding}" VerticalAlignment="Center"  />
                </StackPanel>
            </DataTemplate>
    
            <DataTemplate x:Key="ItemsTemplateWithDataTrigger">
                <ContentControl Template="{StaticResource ImageTemplate}" />
            </DataTemplate>
    
        </Window.Resources>
    
    
        <StackPanel>
            <ContentControl Margin="10" MouseUp="OnImageMouseUp"
                            HorizontalAlignment="Center" Cursor="Hand"
                            DataContext="{Binding Path=ImageEnum}"
                            Template="{StaticResource ImageTemplate}" />
    
            <StackPanel Orientation="Horizontal">
    
                <StackPanel>
                    <ListView Margin="10" 
                      ItemsSource="{Binding Source={StaticResource EnumDataProvider}}" 
                      ItemTemplate="{StaticResource ItemsTemplateWithConverter}" />
    
                    <ComboBox Margin="10" 
                      ItemsSource="{Binding Source={StaticResource EnumDataProvider}}" 
                      ItemTemplate="{StaticResource ItemsTemplateWithConverter}" />
                </StackPanel>
    
                <StackPanel>
                    <ListView Margin="10" 
                      ItemsSource="{Binding Source={StaticResource EnumDataProvider}}" 
                      ItemTemplate="{StaticResource ItemsTemplateWithDataTrigger}" />
    
                    <ComboBox Margin="10" 
                      ItemsSource="{Binding Source={StaticResource EnumDataProvider}}" 
                      ItemTemplate="{StaticResource ItemsTemplateWithDataTrigger}" />
                </StackPanel>
    
            </StackPanel>
        </StackPanel>
    
    </Window>
    

    Code Behind

    using System;
    using System.ComponentModel;
    using System.Globalization;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Data;
    
    namespace WpfSandbox.EnumToImage
    {
        /// <summary>
        /// Interaction logic for EnumToImage.xaml
        /// </summary>
        public partial class EnumToImage : Window
        {
            public EnumToImage()
            {
                InitializeComponent();
            }
    
            private int i = 1;
            private void OnImageMouseUp( object sender, MouseButtonEventArgs e )
            {
                i++;
                Model.ImageEnum = ( Decade )i;
    
                if( i == 6 )
                    i = 0;
            }
        }
    
        public enum Decade
        {
            Ninties = 1,
            Eighties = 2,
            Seventies = 3,
            Sixties = 4,
            Fifties = 5,
            Forties = 6,
        };
    
        public class ImageViewModel : INotifyPropertyChanged
        {
            private Decade _imageEnum;
            public Decade ImageEnum
            {
                get { return _imageEnum; }
                set
                {
                    _imageEnum = value;
                    RaisePropertyChanged( "ImageEnum" );
                }
            }
    
            public ImageViewModel()
            {
                ImageEnum = Decade.Ninties;
            }
    
            public event PropertyChangedEventHandler PropertyChanged;
    
            protected void RaisePropertyChanged( string propertyName )
            {
                var handler = PropertyChanged;
                if( handler != null )
                {
                    handler( this, new PropertyChangedEventArgs( propertyName ) );
                }
            }
    
        }
    
        public class DecadeEnumImageConverter : IValueConverter
        {
            public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
            {
    
                var myEnum = ( Decade )Enum.Parse( typeof( Decade ), value.ToString() );
    
                switch( myEnum )
                {
                    case Decade.Ninties:
                        return "/EnumToImage/images/90s.jpg";
                    case Decade.Eighties:
                        return "/EnumToImage/images/80s.jpg";
                    case Decade.Seventies:
                        return "/EnumToImage/images/70s.jpg";
                    case Decade.Sixties:
                        return "/EnumToImage/images/60s.jpg";
                    case Decade.Fifties:
                        return "/EnumToImage/images/50s.jpg";
                    case Decade.Forties:
                        return "/EnumToImage/images/40s.jpg";
                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }
    
            public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture )
            {
                throw new NotImplementedException();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have the following simple enum: enum Response { Yes = 1,
I have an enum construct like this: public enum EnumDisplayStatus { None = 1,
I have this enum: enum ButtonState { BUTTON_NORMAL = 0, BUTTON_PRESSED = 1, BUTTON_CLICKED
I have this enum: [Flags] public enum ExportFormat { None = 0, Csv =
I have an enum that looks as follows: public enum TransactionStatus { Open =
I have an Enum called Status defined as such: public enum Status { VALID(valid),
I have a Enum for example... public enum TypeIdentifier { NotSet = 0, Type1=
I have an enum public enum FileExtentions { mp3, mpeg } And I have
I have an enum which is used by multiple classes. What is the best
suppose I have an enum [Flags] public enum E { zero = 0, one

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.