我不能为我的生活弄清楚如何将行添加到ListView。我不明白为什么这不起作用,当它适用于ListBox(没有行)时很好..我觉得我错过了这里很简单的东西,有人可以帮我吗?WPF/C#,添加列后添加行到GridView
编辑:没贴的所有代码遗憾
<ListView Margin="10" Name="lvUsers">
<ListView.View>
<GridView>
<GridViewColumn Header="Name" Width="120" />
<GridViewColumn Header="Age" Width="50" />
<GridViewColumn Header="Mail" Width="150" />
</GridView>
</ListView.View>
<StackPanel Orientation="Horizontal" Height="45"> <!--Stacks Items Horizontally-->
<ComboBox Width="100" Height="30">
<ComboBoxItem IsSelected="True">DirecTV</ComboBoxItem>
<ComboBoxItem>Hyundai</ComboBoxItem>
<ComboBoxItem>None</ComboBoxItem>
</ComboBox>
<TextBox Width="445" Height="30" Text="Follow RedZone on Twitter" VerticalContentAlignment="Center"/>
<CheckBox IsChecked="True" VerticalAlignment="Center">
<CheckBox.LayoutTransform>
<ScaleTransform ScaleX="1.5" ScaleY="1.5"></ScaleTransform>
</CheckBox.LayoutTransform>
</CheckBox>
<Button Content="Delete" Height="Auto" Width="Auto" HorizontalAlignment="Right" VerticalAlignment="Top" VerticalContentAlignment="Top"/>
</StackPanel>
</ListView>
您不要将“添加行”添加到GridView中。您将ItemsSource绑定到一些相关的数据项目集合。并让WPF处理UI元素。 –
是谁的列表视图? – Nitin
Listview在哪里? – Sajeetharan