WPF隐藏ItemsControl的第一项(组合框,文本框等)

时间:2018-12-13 10:01:46

标签: wpf xaml

是否有办法仅在纯视图中将xaml中的第一个项目(combobox)控件隐藏在xaml中?

<ItemsControl ItemsSource="{Binding QueueConditionCollection.Collection,
              NotifyOnSourceUpdated=True}"
              AlternationCount="2">
 <ItemsControl.ItemTemplate>
  <DataTemplate>
      <ComboBox Name="cmbLogicalOperator" 
                ItemsSource="{BindingLogicalOperatorCollection.Collection}"
                SelectedItem="{Binding LogicalOperatorCollection.Selected,UpdateSourceTrigger=PropertyChanged}"/>
  </DataTemplate>
 <ItemsControl.ItemTemplate>
</ItemsControl>

实际情况: 如果集合只有一项,则隐藏控件: See this picture

1 个答案:

答案 0 :(得分:0)

您可以声明一个布尔属性,如果Collection.Count()== 1,则该布尔属性将返回false,并为组合框使用布尔到可见性转换器

相关问题