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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:02:31+00:00 2026-05-24T07:02:31+00:00

I have a problem with the ComboBox. The items are displayed when the ComboBox

  • 0

I have a problem with the ComboBox. The items are displayed when the ComboBox is opened. When I select an item and the ComboBox is closing, the ComboBox displaying Model.Person instead of Name, Vorname.

  1. How can I solve that?
  2. How can I realize an auto suggestion?

I have a ComboBox with a DataTamplate.

<ComboBox ItemTemplate="{StaticResource PersonenComboboxTemplate}"
 x:Name="Person1CheckboxName" Text="Choose Person" IsEditable="True"
 ItemsSource="{Binding Path=Personenliste}"
 SelectionChanged="Person1CheckboxName_SelectionChanged" />

<DataTemplate x:Key="PersonenComboboxTemplate">
    <StackPanel Orientation="Horizontal">
        <TextBlock Text="{Binding Path=Name}"/>
        <TextBlock Text=", "/>
        <TextBlock Text="{Binding Path=Vorname}"/>
    </StackPanel>
</DataTemplate>

I use the MVVM-Pattern. The Data Binding is implemented in the ViewModel.

public ObservableCollection<Person> Personenliste
    {
        get
        {
            ObservableCollection<Person> persColl = 
                                              new ObservableCollection<Person>();
            List<Person> personen = 
                          databaseConnection.getAllPersonsRAW().ToList<Person>();
            // sort by Vorname and Nachname
            personen.Sort(new PersonComparer());
            foreach (Person p in personen)
            {
                persColl.Add(p);
            }
            return persColl;
        }
    }

A Person has a given name (Vorname) and a surname (Name). (generated by ADO.NET Entity Data Model)

[EdmEntityTypeAttribute(NamespaceName="dataModel", Name="Person")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public partial class Person : EntityObject
{
    #region Factory-Methode

    /// <summary>
    /// Erstellt ein neues Person-Objekt.
    /// </summary>
    /// <param name="personID">Anfangswert der Eigenschaft PersonID.</param>
    public static Person CreatePerson(global::System.Int64 personID)
    {
        Person person = new Person();
        person.PersonID = personID;
        return person;
    }

    #endregion
    ...
    [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
    [DataMemberAttribute()]
    public global::System.String Name
    {
        get
        {
            return _Name;
        }
        set
        {
            OnNameChanging(value);
            ReportPropertyChanging("Name");
            _Name = StructuralObject.SetValidValue(value, true);
            ReportPropertyChanged("Name");
            OnNameChanged();
        }
    }
    ...
}
  • 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-24T07:02:32+00:00Added an answer on May 24, 2026 at 7:02 am

    Override ToString() in Person class (or partial class) to return Name + " " + Vorname:

    public partial class Person
    {
        public override ToString()
        {
            return string.Format("{0} {1}", Name, Vorname);
        }
    }
    

    Edit:

    Since ToString() is not something that reacts to change notifications, as H.B. pointed out in the comments, you can use this second approach:

    // In PersonPartial.cs
    public partial class Person
    {
        public string DisplayText
        {
            get { return string.Format("{0} {1}", Name, Vorname); }
        }
    
        partial void OnNameChanged()
        {
            OnPropertyChanged("DisplayText");
        }
    
        partial void OnVornameChanged()
        {
            OnPropertyChanged("DisplayText");
        }
    }
    
    <ComboBox ... DisplayMemberPath="DisplayText" />    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to select combobox items by their string value but I have a
I have a problem where scrolling in both a toolStripComboBox and regular ComboBox is
I have this issue with ComboBox that uses IEnumerable<Brush> as ItemsSource; the problem lies
I have a NavigatorContent which is displayed when the user selects an item in
I have created a custom comboBox that supports images in front of the items
I have a combobox that is bound to ObservableCollection<Item> in the ViewModel. When a
I have 2 combobox 1. with items ['item1','item2] 2. is empty. I need to
This may sound trivial but i have a problem with setting selected item in
I have a WPF app that has a combobox with lookup items. The combobox
I have a program where I am trying to select a combobox entry and

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.