在一個ListBoxItem的一個綁定的DataGrid中,我有一個MouseDoubleClick事件是這樣的:刷新上MouseDoubleClick事件
<ListBox HorizontalAlignment="Left" Height="84" Margin="97,599,0,0" VerticalAlignment="Top" Width="88">
<ListBoxItem MouseDoubleClick="Ajout_MouseDoubleClick" Name="Ajouts" Content="Ajouts"/>
The event is as follow:
private void Ajout_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
DbSet<Resultat> res = cnn.Resultat;
var add = from a in res
where a.Remarque.Equals("Ajoute")
select new { a.Groupe_D_alerte, a.LibelléTOTApres, a.LibelléTOTAvant, a.NomChamp, a.NomTable, a.Remarque, a.SiModifie, a.TOTMPMRQ };
cnn.SaveChanges();
DonneesBrutes.Items.Refresh();
}
什麼是應該做的是實現一個LINQ要求轉化到DbSet稱爲Resultat。這是一個簡單的過濾器,在這種情況下是「Remarque」。一旦這個過濾器在DbSet應用,我需要刷新DbSet「雷馬克」
的DataGrid的約束性指標DataGrid中看起來是這樣的:
<DataGrid x:Name="DonneesBrutes" IsReadOnly="True" ItemsSource="{Binding Path=.ResultatCollection}" Margin="10,65,0,0" AutoGenerateColumns="False" EnableRowVirtualization="True" RowDetailsVisibilityMode="VisibleWhenSelected">
<DataGrid.Columns>
<DataGridTextColumn x:Name="PMRQ" Width="*" Binding="{Binding Path=.TOTMPMRQ}" Header="PMRQ"></DataGridTextColumn>
<DataGridTextColumn x:Name="LibellePMRQ" Width="*" Binding="{Binding Path=.LibelléTOTApres}" Header="Libellé PMRQ"></DataGridTextColumn>
<DataGridTextColumn x:Name="Ligne" Width="*" Binding="{Binding Path=.Remarque}" Header="Ligne"></DataGridTextColumn>
<DataGridTextColumn x:Name="OTM" Width="*" Binding="{Binding Path=.TOTMPMRQ}" Header="OTM"></DataGridTextColumn>
<DataGridTextColumn x:Name="TOTM" Width="*" Binding="{Binding Path=.SiModifie}" Header="TOTM"></DataGridTextColumn>
<DataGridTextColumn x:Name="LibelleTOTM" Width="*" Binding="{Binding Path=.LibelléTOTApres}" Header="Libellé OTM"></DataGridTextColumn>
<DataGridTextColumn x:Name="GA" Width="*" Binding="{Binding Path=.Groupe_D_alerte}" Header="GA"></DataGridTextColumn>
<DataGridTextColumn x:Name="Discipline" Width="*" Binding="{Binding Path=.NomTable}" Header="Discipline"></DataGridTextColumn>
<DataGridTextColumn x:Name="DisciplineSubstituee" Width="120" Binding="{Binding Path=.NomChamp}" Header="Discipline Substituée"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
當我雙擊,腳本執行本身,但它沒有發生,我沒有看到DataGrid中應用的過濾器(要將數據從DbSet綁定到DataGrid,我使用ObservableCollection)