Force DataTemplateCell with CellTemplateSelector in WPF DataGrid Autogenerated columns
问题 I have a data grid to which I bind a DataTable. I don't know what rows or columns will be in the data table so I set the AutogenerateColumns property of the data grid to true. The only thing I do know for certain is that every cell in the data table will be of type Field and the Field class has a enum property called Type. <DataGrid x:Name="dg" AutoGenerateColumns="True" ItemsSource="{Binding Path=Fields}" AutoGeneratingColumn="dg_AutoGeneratingColumn"> </DataGrid> What I want to do is to