Abhilash J A

Abhilash J A

  • 525
  • 2.4k
  • 600.7k

How to bind combobox in WPF in C#.Net?

Oct 23 2016 2:10 AM
 Hello everyone,
 
I have arraylist users. 
 
How can I add combobox Zeroth position defult text?
 
  1. <ComboBox ItemsSource="{Binding UserName}" Name="cmbUserName" Height="30"    
  2.           VerticalAlignment="Top" Margin="10,64,614,0"/>  
  1. var logList = service.GetLogDetails();
  2. var UserName = (from A in logList orderby A.FirstName select new UserName { Users = A.FirstName + " " + A.SurName, ID = Convert.ToInt32(A.Id) }).Distinct();  
  3.   
  4. cmbUserName.Text = "Username";   /* How can I add combobox Zeroth position text? */
  5.            cmbUserName.ItemsSource = UserName;  
 
 
I want to add these usernames in Combobox and set ID. Then, pass ID where combobox on change. How can I do this?


 

Answers (4)