[wpf] 可見性差異。混亂和可見性。隱藏



0 Answers

可見性:隱藏的Vs折疊

考慮下面的代碼,它只顯示three Labels並將第二個Label visibility視為Collapsed

 <StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center">
    <StackPanel.Resources>
        <Style TargetType="Label">
            <Setter Property="Height" Value="30" />
            <Setter Property="Margin" Value="0"/>
            <Setter Property="BorderBrush" Value="Black"/>
            <Setter Property="BorderThickness" Value="1" />
        </Style>
    </StackPanel.Resources>
    <Label Width="50" Content="First"/>
    <Label Width="50" Content="Second" Visibility="Collapsed"/>
    <Label Width="50" Content="Third"/>
</StackPanel>

輸出折疊:

現在將第二個Label visibility更改為Hiddden

<Label Width="50" Content="Second" Visibility="Hidden"/>

輸出隱藏:

就如此容易。

Question

WPF中的Visibility.CollapsedVisibility.Hidden之間有什麼區別?




Related