我的申请表中有 combobox
和 datagrid
. datagrid的itemsSource来自其collectionViewSource,并且组合框中有三个 ComboBoxItem
作为警告/错误/异常,如下图所示 .
如何在选择相应的 ComboxBoxitem
时在数据网格上显示selecteditem行详细信息 .
这就是我的尝试 . Combobox - XAML
<ComboBox
SelectedValuePath="{Binding ElementName=dataGrid1,Path=SelectedItem.Type,Mode=OneWay}"
Grid.Column="1" Height="32" HorizontalAlignment="Left" Name="comboBox1" >
<ComboBoxItem Content="Warning"/>
<ComboBoxItem Content="Error"/>
<ComboBoxItem Content="Exception"/>
</ComboBox>
datagrid的XAML
<DataGrid AutoGenerateColumns="False"
IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}" Name="dataGrid1">
有可能通过XAML跳过代码实现这一点吗?如果不是其他建议也是最受欢迎的 .
2 回答
这是一个可以帮助您的代码示例 . 它显示了一个Collection View Source,带有一个过滤器......
XAML
Code Behind
并过滤如下:
Before
After
它只是一个过滤的例子,但它是一个常规的项目控制 .
你可以使用DataGrid的Filter,
有关详细信息,请参阅此处:http://msdn.microsoft.com/en-us/library/ff407126.aspx