WPF Datagrid如下:
<DataGrid Name="gridDetails" AutoGenerateColumns="False" ItemsSource="{Binding Orders}">
<DataGrid.Columns>
<DataGridTextColumn Header="Item Name" Binding="{Binding itemName}" Width="150">
<DataGridTextColumn.ElementStyle>
<Style>
<Setter Property="TextBlock.TextWrapping" Value="Wrap" />
<Setter Property="TextBlock.TextAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTemplateColumn Header="Item Addtionals">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ItemsControl ItemsSource="{Binding ItemAdditionals}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="Quantity" Binding="{Binding quantity}" />
<DataGridTextColumn Header="Price" Binding="{Binding itemPrice}" />
</DataGrid.Columns>
</DataGrid>
任何人都可以帮助我实现所需的输出数据网格格式。
答案 0 :(得分:1)
这看起来像项目名称列中的树视图:
private void Add_Click(object sender, RoutedEventArgs e)
{
using (var db = new Family())
{
var ft = new Father { Name = NewFT.Text };
db.Fathers.Add(ft);
db.SaveChanges();
Fathers.ItemsSource = db.Fathers.ToList();
}
}
使用左边距作为缩进视觉。