Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Phone

Programming Windows Phone 7 : The Intricacies of Layout - Visibility and Layout

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
3/4/2011 8:53:59 AM
The UIElement class defines a property named Visibility that’s handy for temporariliy hiding elements that you don’t want to be visible all the time. The Visibility property is not a Boolean, however. It’s of type Visibility, an enumeration with two members, Visible and Collapsed.

In the previous program, set the Visibility property on one of the elements:

<TextBlock Text="Left, Top, ZIndex" Visibility="Collapsed" />

The value of Collapsed causes the element to have a zero size, and it effectively no longer participates in layout. In some cases that’s exactly what you want, but in this particular case it results in a table with rows that no longer line up correctly:



If you want to hide an element but you still want it to have a non-zero size in the layout, don’t use the Visibility property. Use Opacity instead:

<TextBlock Text="Left, Top, ZIndex" Opacity="0" />

Now the TextBlock has the correct size but is otherwise invisible:



That’s almost correct. One possible problem is that the TextBlock will still respond to touch input. If you want to completely hide it from both sight and touch, use:

<TextBlock Text="Left, Top, ZIndex"
Opacity="0"
IsHitTestVisible="False" />

Opacity is not nearly as efficient as Visibility when used for layout purposes, so try to avoid it if you’re doing something that requires frequent layout cycles. (And if you’re wondering why Visibility is not a Boolean, it’s because of the Windows Presentation Foundation. In WPF, the Visibility enumeration has a third member named Invisible, which hides the element visually but retains its size for layout purposes.)

The Visibility and Opacity properties apply to an element and the element’s children, so if you set these properties on a panel, they apply to the panel’s children as well.

If you set a RenderTransform property on a panel, the panel’s children will also be affected by the transform. However, if you set a RenderTransform on a child of a panel, then the parent panel will ignore any effects the RenderTransform has when laying out its children.

Other -----------------
- Programming Windows Phone 7 : The Intricacies of Layout - Nested Panels
- Programming Windows Phone 7 : The Intricacies of Layout - Text Concatenation with StackPanel
- Programming Windows Phone 7 : The Intricacies of Layout - The StackPanel Stack
- Programming Windows Phone 7 : The Intricacies of Layout - The Single-Cell Grid
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server