0
我正在嘗試使用組合框篩選DataGrid中的數據。使用組合框篩選DataGrid
我有這樣的XAML:
<ComboBox x:Name="cmbFilter" SelectionChanged="cmbFilter_SelectionChanged" />
<Grid>
<DataGrid x:Name="dataList">
<DataGrid.Columns >
<DataGridTextColumn Header="School" Binding="{Binding SchoolName}"></DataGridTextColumn>
<DataGridTextColumn Header="Category" Binding="{Binding CategorySchool}"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
而且在後面的代碼:
//fill the list with the datas
this.dataList.ItemsSource = MainWindow._RE.ListDatas;
//fill the combobox with the school names
this.cmbFilter.ItemsSource = MainWindow._RE.ListNameSchool;
private void cmbFilter_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// ??????
}
我管理的所有學校名稱填寫在DataGrid的所有DATAS等組合框。 我想要的是能夠過濾Datagrid,具體取決於從ComboBox中選擇「School」列的學校名稱。所顯示的數據是隻有那些從學校在ComboBox中選定
謝謝
謝謝你,就像一個魅力!我不能+1你的評論,因爲我還沒有15聲望.. – 281
@ 281,不客氣 –