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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:33:56+00:00 2026-06-04T18:33:56+00:00

all, I am really stuck on a very basic concept – I just cannot

  • 0

all,

I am really stuck on a very basic concept – I just cannot find an answer that I really understand.

I have a view – viewContacts. Its datacontext is a viewmodel – viewmodelContacts.

On the view I have a combobox for ‘titles’ (you know … Mr, Mrs, Miss, etc). I want to bind the itemssource so it shows a list of options, and bind the SelectedValue so that it stores the key in the viewmodelContacts TitleId property.

The ‘source’ list if titles (that I want to bind ItemsSource to) is actually in a separate static class – note NOT the viewmodel!

internal static class Titles
{
    static IList<Title> _colTitles = null;
    static Titles()
    {
        _colTitles = new List<Title>();
        _colTitles.Add(new Title() { TitleId = 1, Description = "Mr." });
        _colTitles.Add(new Title() { TitleId = 2, Description = "Mrs." });
        _colTitles.Add(new Title() { TitleId = 3, Description = "Miss." });
        _colTitles.Add(new Title() { TitleId = 4, Description = "Ms." });
    }

    internal static IList<Title> GetTitles()
    {
        return _colTitles;
    }
}

(later on, of course, this stuff will be fetched from a database).

This simple task exceeds my talent as a WPF developer.

How do I set the ItemsSource to this static class? How do I further set the DisplayMemberPath to the Description property of the underlying Title object?

What do I set the SelectedValue and SelectedValuePath to?

Really hoping someone can help me out with what appears to be a simple problem that I just cannot work out.

Thanks,
Gray

  • 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-04T18:33:58+00:00Added an answer on June 4, 2026 at 6:33 pm

    In your viewModel create a property like so:

    public IList<Title> VmTitles
    {
        get
        {
            return Titles.GetTitles();
        }
    }
    
    private Title _selectedTitle;
    public Title SelectedTitle
    {
        get
        {
            return _selectedTitle;
        }
        set
        {
            if (value != _selectedTitle)
            {
                _selectedTitle = value;
                OnPropertyChanged("SelectedTitle");
            }
        }
    }
    

    Then in your .xaml you do this:

    <ComboBox x:Name="cboTitle" ItemsSource="{Binding Path=VmTitles}" DisplayMemberPath="Description" SelectedItem="{Binding Path=SelectedTitle}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some very long draggable elements that I can drop in all cells
The rails books and web pages I've been following have all stuck to very
All, I am really stuck/ confused at this point. I have an array with
I am really liking having all of my view's laid out in the Storyboard
All the questions I have dug through in the boards aren't really answering a
I'm really stuck in doing routes for my app and I find rooting in
I have a very dynamic web app that is dynamically created controls at run-time.
I have a Windows service that has a number of threads that all need
Have been stuck with this issue for a few days now, and really need,
Note that I'm really looking for an answer to my question. I am not

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.