DataGridColumn with Header '*' already exists in the Columns collection of a DataGrid
问题 I have a WPF application with MVVM pattern. In one of my view, I have to bind an ObservableCollection to view. In that view, I have one ListBox and one DataGrid both bind to the same ObservableCollection but doing different things like events, style etc.. I need only one of these controls displayed at a time and what I did is created two user controls, one for DataGrid and other for ListBox . And I switched between them by placing a ContentControl on the main view(something similar to this