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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:21:32+00:00 2026-06-07T10:21:32+00:00

I had databinding set up like this: ItemsSource={Binding Source={my:Enumeration {x:Type credit:OccupationCategory}}} DisplayMemberPath=Description SelectedValue={Binding EmplType}

  • 0

I had databinding set up like this:

ItemsSource="{Binding Source={my:Enumeration {x:Type credit:OccupationCategory}}}"
                      DisplayMemberPath="Description"
                      SelectedValue="{Binding EmplType}"
                      SelectedValuePath="Value"/>

and it worked really well. Do to a change in the larger software design I can no longer have anything that generates an INotifyPropertyChanged Event so that type of databinding doesn’t work. Instead I am manually setting the selectedIndex and building the options from code like this:

ItemsSource="{Binding Source={StaticResource ResidenceOwnershipType}}"/>

which references

<UserControl.Resources>
    <ObjectDataProvider x:Key="ResidenceOwnershipType" MethodName="GetValues" ObjectType="{x:Type System:Enum}" >
        <ObjectDataProvider.MethodParameters>
            <x:Type TypeName="credit:ResidenceOwnershipType" />
        </ObjectDataProvider.MethodParameters>
    </ObjectDataProvider>
</UserControl.Resources>

That works as far as the building of the list options is concerned and the linking of all of my data, but I can’t get the comboboxes to show the description tag in the enumeration instead of the actual text.

I’ve tried something like this:

DisplayMemberPath="Description"

but that wasn’t correct. How would I go about doing this?

EDIT:

My Enum:

[DataContract]
public enum ResidenceOwnershipType
{
    [Description("")]
    None = 0,
    [Description("Owns Home Outright")]
    OwnsHomeOutright = 1,
    [Description("Buying Home")]
    BuyingHome = 2,
    [Description("Renting/Leasing")] //Weird order here reflects RouteOne website
    RentingLeasing = 4,
    [Description("Living w/Relatives")]
    LivingWithRelatives = 3,
    [Description("Owns/Buying Mobile Home")]
    MobileHome = 5,
    [Description("Unknown")]
    Unknown = 6
}
  • 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-07T10:21:34+00:00Added an answer on June 7, 2026 at 10:21 am

    If you keep this ItemsSource you will have to define a custom ItemTemplate as the DisplayMemberPath is just a path via which you will not be able to retrieve the description.

    As for what the template should look like: You can bind a TextBlock to the enum value (the current DataContext) and pipe that through a ValueConverter using Binding.Converter. The code would just be some reflection to retrieve the Description (GetType, GetCustomAttributes etc.)

    Alternatives are a custom method that return a usable collection right away (and is used in the ObjectDataProvider) or a custom markup extension which does the same thing.


    Method example if we are talking about a ComponentModel.DescriptionAttribute:

    public static class EnumUtility
    {
        // Might want to return a named type, this is a lazy example (which does work though)
        public static object[] GetValuesAndDescriptions(Type enumType)
        {
            var values = Enum.GetValues(enumType).Cast<object>();
            var valuesAndDescriptions = from value in values
                                        select new
                                            {
                                                Value = value,
                                                Description = value.GetType()
                                                    .GetMember(value.ToString())[0]
                                                    .GetCustomAttributes(true)
                                                    .OfType<DescriptionAttribute>()
                                                    .First()
                                                    .Description
                                            };
            return valuesAndDescriptions.ToArray();
        }
    }
    
    <ObjectDataProvider x:Key="Data" MethodName="GetValuesAndDescriptions"
                        ObjectType="local:EnumUtility">
        <ObjectDataProvider.MethodParameters>
            <x:TypeExtension TypeName="local:TestEnum" />
        </ObjectDataProvider.MethodParameters>
    </ObjectDataProvider>
    
    <ListBox ItemsSource="{Binding Source={StaticResource Data}}"
             DisplayMemberPath="Description"
             SelectedValuePath="Value"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If a set of controls on a WinForm have had DataBindings created and attached
Had this working; at one stage. The problem is the following text is now
I had this problem before and can't for life of me remember how to
Ok so I had a qustion awhile back regarding Silverlight 4 Data Binding with
I'm very new to databinding, and so far have only had luck databinding to
I have a DataGridView that uses databinding, with manually created columns, and this works
Had this: $(function(){ $(a.next.down).click(function() { $(ul.panel li).addClass(upOne); $(a.next).removeClass(down).addClass(downTwo); }); $(a.next.downTwo).click(function() { $(ul.panel li).addClass(upTwo); $(a.next).removeClass(downTwo).addClass(downThree);
I recently had an issue with databinding to the Visibility property of a DataGridTextColumn.
Have anybody had a isse with comments <!--´comment --> and XML data binding in
I am successfully databinding and using WPF Comboboxes and have had some success with

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.