【发布时间】:2021-09-27 23:15:51
【问题描述】:
我的情况与此问题类似: Displaying Content only when ListViewItem is Selected
我有一个 ComboBox,我只想在包含它的 ListViewItem 被选中并且 ComboBox 不为空时显示(这两个条件都必须为真)。将可见性绑定到只读属性非常容易,该属性检查 ViewModel 中的 ItemsSource 属性是否有任何项目,并且通过上面的链接还解决了如何仅在选择 ListViewItem 时才显示它,但我无法加入这两个条件。如何仅在选中项目且组合不为空时才显示 ComboBox?
ComboBox 中的这种样式的作用是仅在被选中时才显示:
<ComboBox ItemsSource="{Binding DataContext.ListaPedidosPendientes, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}" DisplayMemberPath="numero">
<ComboBox.Style>
<Style TargetType="{x:Type ComboBox}">
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
AncestorType={x:Type ListBoxItem}},Path=IsSelected}" Value="True">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ComboBox.Style>
</ComboBox>
如何添加第二个条件 (ListaPedidosPendientes.Count > 0)?
谢谢
【问题讨论】:
标签: wpf xaml datatrigger