<DataGrid Name="employeesDataGrid" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridCheckBoxColumn
xmlns:myconv="clr-namespace:MyProject.Converters"
Binding="{Binding enabled, Converter={myconv:IntToBool}}"
Header="Enabled">
<DataGridCheckBoxColumn.CellStyle>
<Style>
<EventSetter Event="CheckBox.Checked" Handler="OnChecked" />
</Style>
</DataGridCheckBoxColumn.CellStyle>
</DataGridCheckBoxColumn>
<DataGridTextColumn
Binding="{Binding proxyFor}"
Header="Proxy For"
/>
</DataGrid.Columns>
</DataGrid>
Code Behind
private void OnChecked(Object sender, RoutedEventArgs e)
{
// Not sure what to do here.
}
How do I keep track of whats changed in the DataTable or the selected row?
I am loaded this at Initialize() with the following code
using (OleDbConnection con = new OleDbConnection(connectionString))
{
dt = new DataTable("accesscontrol");
CmdString = "SELECT proxyFor, enabled FROM accesscontrol WHERE currentlyLoggedOnUser = @userName";
OleDbCommand cmd = new OleDbCommand(CmdString, con);
cmd.Parameters.AddWithValue("userName", Environment.UserName);
using (adapter = new OleDbDataAdapter(cmd))
{
adapter.Fill(dt);
}
employeesDataGrid.ItemsSource = dt.DefaultView;