0
编程的ListView我有一个ListView WPF中添加组合框在WPF
<ListView Name="listArea">
<ListView.View>
<GridView>
<GridViewColumn x:Name="colName" Header="نام تحویلدار" Width="150" DisplayMemberBinding="{Binding Path=name}"/>
<GridViewColumn x:Name="colComboBox" Header="منطقه" Width="120" DisplayMemberBinding="{Binding Path=cb}"/>
</GridView>
</ListView.View>
</ListView>
我想补充项目列表视图。第一列是文本,secound是comboBox。
foreach(personel ptahvildar in STATICS.db.personels.Where(q=>q.postCode==2))
{
ListViewItem item = new ListViewItem();
ComboBox cbox = new ComboBox();
cbox.ItemsSource = STATICS.db.personels.Where(q => q.postCode == 2);
cbox.DisplayMemberPath = "name";
cbox.SelectedItem = ptahvildar;
item.Content = new { name = ptahvildar.name, cb = cbox };
listArea.Items.Add(item);
}
但结果却是这样
为什么我的组合框无法正确显示?
每个combobox.selecteditem依赖于另一列的值...我如何通过另一列值后面的代码和改变comboBox selecteditem? – abbas
CommandParameter负责将值传递给Command。您可以将项目中的特定字段(列)传递给事件。正如我所说的,你必须使用适当的绑定,因为我只是从SO中的一些答案中提取样本。 –