WPF DataGrid ItemsSource 绑定时的元素修改

发布时间 2024-01-04 14:56:03作者: 悠哉境園

xml 片段:
<DataGrid Grid.Row="1" Height="400" Margin="3" ItemsSource="{Binding RecipeTable}" SelectedIndex="{Binding sRow}" AutoGenerateColumns="False" CanUserAddRows="False" AlternationCount="2" RowStyle="{StaticResource DataGridRowStyle}">
ViewModel 片段:
foreach (var item in RecipeTable) { item.RecipeTableColumn0 = tableID.ToString(); tableID++; Console.WriteLine(item.RecipeTableColumn0.ToString()); }