0
ComboBoxを使用してDataGridでデータをフィルタリングしようとしています。ComboBoxを使用した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をフィルタリングできることです。表示されたデータのみをコンボボックスで選択した学校からのものであることを
はあなたがWhere()
を使用することができますあなたの
は、ありがとう魔法のように動作します!私はまだ15の評判を持っていないので、あなたのコメントを+1することはできません。 – 281
@ 281、あなたは歓迎です –