Reputation: 4570
I have an ItemSource that is bounded to a DataGrid. However, all of the properties of the ItemSource is being shown in the grid, but I have only specified a few columns (properties) that I want the user to see and modify in the XAML
<DataGrid.Columns>
.. Column 1...
.. Column 2...
</DataGrid.Columns>
I am guessing there is a property of the grid that I will need to set to false so it only shows the columns or properties that I have personally specified.
If not, any ideas of how I can achieve this?
Thanks
Upvotes: 0
Views: 749
Reputation: 81323
Set AutoGenerateColumns=False
on dataGrid and provide your own set of columns under Columns
tag.
<DataGrid AutoGenerateColumns="False" ItemsSource="{Binding SourceCollection}">
<DataGrid.Columns>
<DataGridTextColumn Header="Id" Binding="{Binding Id}"/>
<DataGridTextColumn Header="Name" Binding="{Binding Name}"/>
</DataGrid.Columns>
</DataGrid>
Upvotes: 1