我是WPF的新手,我想将一个小的胜利形式的应用程序转换为WPF应用程序。WPF使用linq的combobx绑定
我使用LINQ-SQL和下面是dbml的文件
这是我有1个组合框和其他文本框
<ComboBox Height="23" IsDropDownOpen="False" Margin="107,52,281,0" Name="cbx_contact" VerticalAlignment="Top" />
<Label Height="17" HorizontalAlignment="Left" Margin="25,55,0,0" VerticalAlignment="Top" Width="72">Contact :</Label>
<TextBox Height="23" Margin="107,85,281,0" Name="txt_name" VerticalAlignment="Top" />
<Label Height="23" HorizontalAlignment="Left" Margin="25,89,0,0" Name="label2" VerticalAlignment="Top" Width="72">Name* :</Label>
<TextBox Height="23" Margin="107,118,281,0" Name="txt_cellno" VerticalAlignment="Top" />
<Label Height="23" HorizontalAlignment="Left" Margin="25,121,0,0" Name="label3" VerticalAlignment="Top" Width="72">Cell No.* :</Label>
<TextBox Height="23" Margin="107,0,281,173" Name="txt_add1" VerticalAlignment="Bottom" />
<Label Height="18.025" HorizontalAlignment="Left" Margin="25,0,0,176" Name="label4" VerticalAlignment="Bottom" Width="72">Address1 :</Label>
<TextBox Height="23" Margin="107,0,281,140" Name="txt_add2" VerticalAlignment="Bottom" />
<Label Height="23" HorizontalAlignment="Left" Margin="25,0,0,138" Name="label5" VerticalAlignment="Bottom" Width="72">Address2 :</Label>
<TextBox Height="23" Margin="107,0,281,107" Name="txt_city" VerticalAlignment="Bottom" />
我想结合我的XAML代码文件组合框到显示成员“名称”和值成员“联系ID”的联系人表
我尝试了不同的方法,但没有任何工作为m è...
这里是赋予错误
DataClasses1DataContext db = new DataClasses1DataContext();
var sel = from contact in db.Contacts select new { contactid = contact.ContactID, name = contact.Name };
cbx_contact.ItemsSource = sel;
cbx_contact.DisplayMemberPath = "name";
cbx_contact.SelectedValuePath = "contactid";
我收到以下错误代码: 无法创建的“CONTACT_FORM”汇编定义的“WpfApplication2例如,版本= 1.0.0.0,文化=中立,PublicKeyToken = null'。异常是由调用的目标引发的。标记文件'WpfApplication2; component/Contact_form.xaml'第1行位置错误7.
请给我链接绑定wpf gridview的好例子。 ListView和组合框提前
内部的异常会非常有用,因为它应该说明发生了什么。 – flq 2011-04-21 12:29:05
谢谢@flq .. {“异常已被调用的目标引发。”}这是内部异常.. – 2011-04-21 12:31:12