public class PushTable { public long id { get; set; } public string sn { get; set; } public string obis { get; set; } public string date { get; set; } public long evcode { get; set; } public int ReadBool { get; set; } public PushTable() { ReadBool = 0; // this row in the database should change to "1", after double clicking on the cell } }
<DataGrid x:Name="tableNoRead" AutoGenerateColumns="False" Width="Auto" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" CanUserResizeRows="False" IsReadOnly="True" SelectionMode="Single" FontSize="25" ItemsSource="{Binding}"> <DataGrid.Resources> <Style TargetType="DataGridRow"> <EventSetter Event="MouseDoubleClick" Handler="Row_DoubleClick"/> </Style> </DataGrid.Resources> <DataGrid.Columns> <DataGridTextColumn Header="ИД" Binding="{Binding id}" Width="3*"/> <DataGridTextColumn Header="Серийный номер" Binding="{Binding sn}" Width="10*"/> <DataGridTextColumn Header="OBIS" Binding="{Binding obis}" Width="10*"/> <DataGridTextColumn Header="Date" Binding="{Binding date}" Width="10*"/> <DataGridTextColumn Header="EvCode" Binding="{Binding evcode}" Width="10*"/> </DataGrid.Columns> </DataGrid>
private void Row_DoubleClick(object sender, MouseButtonEventArgs e) { if (tableNoRead.SelectedItem != null) { //db.PushTables.Add(new PushTable() { id = 444, sn = "sd", obis = "dsa", evcode = 213, date = "sdsad" }); //db.SaveChanges(); //tableNoRead.ItemsSource = db.PushTables.ToList(); db.PushTables.Remove(tableNoRead.SelectedItem as PushTable); db.SaveChanges(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)