WPF Combobox SelectedValuePath?

How can i add selected value path to two items in the struct/class ? In the below example i want to add SelectedValuePath as Id1*Id2

this.cboXXX.ItemsSource = Employee;
this.cboXXX.DisplayMemberPath = "Name";
*this.cboXXX.SelectedValuePath = "Id1" + "*" + "Id2";* ??


public struct Employee
{
   public int Id1;
   public int Id2;
   public string Name;
}

Answers


You can't because SelectedValuePath is the object property path. You could do this, though...

this.cboXXX.DisplayMemberPath = "Name";
this.cboXXX.SelectedValuePath = "CombinedID";

public struct Employee
{
    public int _Id1;
    public int Id1 
    { 
        get {return _Id1;} 
        set
        {
            _Id1 = value;
            CombinedID = Id1 + "*" + Id2;
        } 
    }
    public int _Id2;
    public int Id2
    {
        get { return _Id1; }
        set
        {
            _Id1 = value;
            CombinedID = Id1 + "*" + Id2;
        }
    }

    public string CombinedID {get;set;}
    public string Name;
}

Need Your Help

What is the upper bound on the number of antipodal pairs?

geometry computational-geometry convex-hull

Antipodal pair is pair of vertices x,y such that we can draw parallel tangents to convex-hull H through vertex x and y without intersecting H.

How to highlight row for IsSelected

wpf xaml listview background itemcontainerstyle

I want to highlight the row when I select from my ListView but I cant get it to work. Can anyone look at what I have and tell me what I'm doing wrong? Another question is What about having a proper...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.