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
Width
I added this columns inside<DataGrid.Columns>
and now i can see myData Grid
columns but if I add this manually every column appears twice.In my
Person
class I have another member -DataTime
that I don't want to see inside myDataGrid
but addContext Menu
click and then show this Value. How can I remove it from myDataGrid
?