将LINQ结果绑定到ComboBox

时间:2016-10-29 16:37:45

标签: c# wpf linq combobox

从此LINQ查询中

 var usernames = (from A in logList orderby A.FirstName select new 
  UserName { Users = A.FirstName + " " + A.SurName, ID = Convert.ToInt32(A.Id) }).Distinct();

我想将用户名与ID绑定到ComboBox



 <ComboBox  Name="cmbUserName" Height="30"  
          VerticalAlignment="Top" Margin="10,64,614,0"/>
&#13;
&#13;
&#13;

Linq结果显示,

enter image description here

每个列表项中包含ID和用户。

enter image description here

0 个答案:

没有答案