I have this View Model:
public class Person
{
public bool Selected;
public string Name;
public bool IsMaried;
public DataTime bDay;
}
List<Person> col;
And this is my DataGrid:
<DataGrid
Grid.Row="1"
Name="dataGrid"
ItemsSource="{Binding col}">
<DataGrid.Columns>
<DataGridTemplateColumn Width="60" Header="Select" SortMemberPath="IsSelected">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<CheckBox IsChecked="{Binding Selected}" />
<Image/>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn
Header="Name"
Binding="{Binding Name}"
Width="180"/>
</DataGrid.Columns>
</DataGrid>
I have several issues:
In order to configure columns
WidthI added this columns inside<DataGrid.Columns>and now i can see myData Gridcolumns but if I add this manually every column appears twice.In my
Personclass I have another member -DataTimethat I don't want to see inside myDataGridbut addContext Menuclick and then show this Value. How can I remove it from myDataGrid?