设计时WPF中的多列listview
我在这里可能听起来很傻,但我想做一些非常简单的事情。在设计时,我想向listview控件添加列,并向其中添加一些数据。我需要在listview的每一列中添加combobox。我找不到在listviewitem中提到列号的位置。任何帮助都是值得感激的设计时WPF中的多列listview,wpf,listview,Wpf,Listview,我在这里可能听起来很傻,但我想做一些非常简单的事情。在设计时,我想向listview控件添加列,并向其中添加一些数据。我需要在listview的每一列中添加combobox。我找不到在listviewitem中提到列号的位置。任何帮助都是值得感激的 <ListView IsSynchronizedWithCurrentItem="True" Margin="8,68,304,188" BorderThickness="2,2,2,2"> <ListView.V
<ListView IsSynchronizedWithCurrentItem="True" Margin="8,68,304,188"
BorderThickness="2,2,2,2">
<ListView.View>
<GridView>
<GridViewColumn Width="150" Header="Column1"/>
<GridViewColumn Width="150" Header="Column2"/>
</GridView>
</ListView.View>
<ListViewItem>
</ListViewItem>
</ListView>
listviewitem中的每一列都是基于GridView定义呈现的,因此没有真正的列号概念。您要做的是将对象绑定到listview的itemsource,并从中创建listviewitems。因此,有几个篮筐可以跳过 有一个如何进行简单对象数据绑定的示例。这样做的好处是,如果将datacontext/itemsource设置为空对象而不是XAML中的静态对象,那么设计时的绑定结构可能可以在运行时重用 如果您这样做是为了展示示例,或者只是想使用静态数据源,我建议您使用。然后将ListView更改为这样
<ListView IsSynchronizedWithCurrentItem="True" Margin="8,68,304,188"
BorderThickness="2,2,2,2">
<ListView.View>
<GridView>
<GridViewColumn Width="150" Header="Column1" DisplayMemberPath="{Binding XPath=/A/B}"/>
<GridViewColumn Width="150" Header="Column2" DisplayMemberPath="{Binding XPath=/A/C"/>
</GridView>
</ListView.View>
<ListViewItem>
</ListViewItem>
</ListView>
是的,我想我是在寻找一个从未存在过的东西:)。装订是一种方式。谢谢