隐藏基于属性的数据网格中的项目 [英] Hide items in a datagrid based on a property
本文介绍了隐藏基于属性的数据网格中的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在ItemsSourc项目具有等于true的.Filter属性的DataGrid中隐藏项目.
I''m trying to hide items in a DataGrid where the ItemsSourc item has a .Filter property equal to true.
<datagrid grid.row="1" itemssource="{Binding SelectedScan.Runs}" isreadonly="True" autogeneratecolumns="False" selecteditem="{Binding SelectedDatum}">
<datagrid.itemtemplate>
<datatemplate>
//this is where i''m assuming it should go
</datatemplate>
</datagrid.itemtemplate>
<datagrid.columns>
<datagridtemplatecolumn header="Commands">
<datagridtemplatecolumn.celltemplate>
<datatemplate>
<stackpanel orientation="Horizontal">
<Button Content="Whitelist" Padding="0,-2,0,-2" Margin="0" Command="{Binding DataContext.TableFilterViewModel.AddWhitelistItemCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}" CommandParameter="{Binding .}" />
<Button Content="{x:Static Properties:Resources.OpenShare}" Command="{Binding DataContext.GrabFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" CommandParameter="{Binding .}" Padding="-2" Margin="0" />
</stackpanel>
</datatemplate>
</datagridtemplatecolumn.celltemplate>
</datagridtemplatecolumn>
<datagridtextcolumn width="200" binding="{Binding Name}" header="Program" />
<datagridtextcolumn width="450" binding="{Binding Value}" header="Location" />
</datagrid.columns>
</datagrid>
推荐答案
是否可以将整个项目模板放在容器中并绑定其Visible属性?您需要具有一个与Filtered相反的属性来绑定(或编写一个反向绑定转换器),但这很容易.
Can you not put the whole item template inside a container and bind its Visible property? You would need to have a property that was the opposite of Filtered to bind to (or write an inverting binding converter), but that is easy enough.
这篇关于隐藏基于属性的数据网格中的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文