下面是一个细艺术作品,表示与在左列表框和右侧的内容控制一个WPF形式。我想设置它,如果列表框为空,则内容控制是不可见的。什么属性/事件,我应该勾?

----- -----
| a | | c |
| b | |   |
----- -----
有帮助吗?

解决方案

您应该创建了该ContentControl中一种风格,并使用触发器来确定何时名单有0项,像这样:

<ListBox x:Name="uiList">...</ListBox>
<ContentControl>
        <ContentControl.Content>
            <TextBox Text="List has items." />
        </ContentControl.Content>
        <ContentControl.Style>
            <Style TargetType="{x:Type ContentControl}">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding ElementName=uiList, Path=Items.Count}"
                                 Value="0">
                        <Setter Property="Visibility"
                                Value="Collapsed" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </ContentControl.Style>
    </ContentControl>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top