原文:WPF 在使用 ItemsSource 之前,项集合必须为空
- <DataGrid x:Name="datagrid" ItemsSource="{Binding ElementName=Mwindow, Path=Preson}" Margin="0,0,0,20">
- <DataGrid.Columns>
- <DataGridTextColumn Binding="{Binding Name}" Header="Name"></DataGridTextColumn>
- <DataGridTextColumn Binding="{Binding Address}" Header="Address"></DataGridTextColumn>
- <DataGridTextColumn Binding="{Binding Age}" Header="Age"></DataGridTextColumn>
- </DataGrid.Columns>
- </DataGrid>
DataGridTextColumn 一定要在 <DataGrid.Columns>里
原文地址:https://www.cnblogs.com/lonelyxmas/p/12075452.html
时间: 2024-10-07 15:22:42