private void ViewWinLoaded(object sender, RoutedEventArgs e)
{
var stud = from s in data.Students
select s;
Student[] st=stud.ToArray<Student>();
datagrid.ItemsSource = st;
}
以上是我的 C# 代码。
<DataGrid x:Name="datagrid" HorizontalAlignment="Left" Height="232" VerticalAlignment="Top" Width="461">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Path=StudentID}" ClipboardContentBinding="{x:Null}" Header="StudentID"/>
<DataGridTextColumn Binding="{Binding Path=FirstName}" ClipboardContentBinding="{x:Null}" Header="First Name"/>
<DataGridTextColumn Binding="{Binding Path=LastName}" ClipboardContentBinding="{x:Null}" Header="Last Name"/>
<DataGridTextColumn Binding="{Binding Path=Gender}" ClipboardContentBinding="{x:Null}" Header="Gender"/>
<DataGridTextColumn Binding="{Binding Path=GPA}" ClipboardContentBinding="{x:Null}" Header="GPA"/>
</DataGrid.Columns>
</DataGrid>
我想要实现的是使用我自己的列名,而不是分贝中的列名。但是当我运行代码时,它会同时显示我的自定义列和数据库中的列名(级联名称)