Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Window Visibility, collapsed and hidden

I have a quick question regarding visibility of windows in an application. According to... http://msdn.microsoft.com/en-us/library/system.windows.visibility.aspx (its short)

When a window is collapsed no space is reserved for the window in layout. When a window is hidden space is reserved for the window in layout.

I'm confused here, what is the layout referring to? Is it referring to window space?

like image 219
Ben Cheng Avatar asked Dec 25 '22 18:12

Ben Cheng


2 Answers

Here's an illustration:

 <Grid>
        <TabControl>
            <TabItem Header="Visible"></TabItem>
            <TabItem Visibility="Hidden" Header="Hidden">Hidden</TabItem>
            <TabItem Visibility="Hidden" Header="Hidden">Hidden</TabItem>
            <TabItem Visibility="Hidden" Header="Hidden">Hidden</TabItem>
            <TabItem Header="Visible"></TabItem>
            <TabItem Header="Visible"></TabItem>
            <TabItem Header="Visible"></TabItem>
        </TabControl>
    </Grid>

Will render this:
enter image description here

And this XAML:

<Grid>
    <TabControl>
        <TabItem Header="Visible"></TabItem>
        <TabItem Visibility="Collapsed" Header="Collapsed">Collapsed</TabItem>
        <TabItem Visibility="Collapsed" Header="Collapsed">Collapsed</TabItem>
        <TabItem Visibility="Collapsed" Header="Collapsed">Collapsed</TabItem>
        <TabItem Header="Visible"></TabItem>
        <TabItem Header="Visible"></TabItem>
        <TabItem Header="Visible"></TabItem>
    </TabControl>
</Grid>

Will render this:

enter image description here

So, Collapsed will not save the space, whereas Hidden will.

like image 152
Tico Avatar answered Jan 13 '23 04:01

Tico


No, its referring to the whole window you are looking at.

Lets say, you have at the top of the screen a Red Block (20px height) and below the Red Block you have a title.

Hidden: The Red Block is NOT visible, but the space it normally reserves, is still reserved, meaning the Title is is 20px away from the top of the screen

Collapsed: The Red Block is NOT visible together with the reserved space (the 20px height), meaning the Title is located at the top of the screen

like image 43
pazcal Avatar answered Jan 13 '23 03:01

pazcal