Here is my Employee class.
public class Employee
{
public string LastName { get; set; }
public string FirstName { get; set; }
public bool Fire { get; set; }
}
This is how XAML is setup.
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid Loaded="EmployeesGridLoaded">
<DataGrid x:Name="gEmployees" HorizontalAlignment="Left" Margin="10,10,0,0"
VerticalAlignment="Top" AlternatingRowBackground="LightBlue" AlternationCount="2" AutoGenerateColumns="False" Grid.Row="0">
<DataGrid.Columns>
<DataGridCheckBoxColumn Header="Fire" Binding="{Binding Fire}" Width="1*" />
<DataGridTextColumn Header="Last Name" Binding="{Binding LastName}" Width="3*" />
<DataGridTextColumn Header="First Name" Binding="{Binding FirstName}" Width="3*" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>
And finally here is the EmployeesGridLoaded method.
private void EmployeesGridLoaded(object sender, RoutedEventArgs e)
{
List<Employee> Employees = new List<Employee>()
{
new Employee() { Fire = false, LastName = "Silly", FirstName = "Dude" },
new Employee() { Fire = false, LastName = "Mean", FirstName = "Person" },
};
gEmployees.ItemsSource = Employees;
}
}
Through this grid, my goal is that last & first name columns should be read-only. I also don't want to have ability to add a new row but I want the Fire column as editable, so that I can choose which employees I want to fire. Below is what I am getting.

I know that I can set binding mode to One-way which will make last and first name columns non-ediable but with that I still get an extra empty row in the grid. Can you please help me solve this problem so that I can start firing employees?