We will also use hiding an element in WP to achieve a certain effect. I have just read the article and will share it with you [Author: shenzhenlong]
Visibility
This attribute can easily hide an element. However, the visibility attribute is not of the boolean type but is of the visibility type and contains the enumeration types of two members, visibility and collapsed:
By default, the attribute is displayed as visible. When set to collapsed, the element size changes to 0. When set to collapsed, the element to which this attribute belongs is not involved in the event, in addition, you cannot obtain the focus. If you do not obtain the focus, you cannot perform a hit test.
XAML code:
<! -- Contentpanel-place other content here --> <grid X: Name = "contentpanel" grid. row = "1" margin = "12, 0, 12, 0"> <textblock X: name = "tb1" text = "tb1 display" verticalalignment = "center" horizontalalignment = "center"> </textblock> <textblock X: name = "tb2" text = "tb2 display" visibility = "Collapsed" verticalignment = "center"> </textblock> </GRID>
Before adding visibility = "Collapsed"
After adding visibility = "Collapsed"
However, if this attribute is used during the layout process, changing the size of an element to 0 may affect the layout;
Opactity
Yes, this is the property. I did not expect it to be this property before I saw it, but think about it carefully. When opactity = "0, you can set the transparency of an element to the lowest, and you will not be able to see it. However, this element actually exists. Therefore, this attribute can be used without affecting the layout, and the element will not disappear.
XAML code:
<Grid X: Name = "contentpanel" grid. row = "1" margin = "12, 0, 12, 0"> <textblock X: name = "tb1" text = "tb1 display" verticalalignment = "center" horizontalalignment = "center"> </textblock> <textblock X: name = "tb2" text = "tb2 display" opacity = "0" verticalignment = "center" manipulationdelta = "tb2_manipulationdelta"> </textblock> </GRID>
Effect after running:
Like the previous image, we can see from the code that we have defined a touch movement event to see if it will be implemented. The code for hiding a file is relatively simple, as shown below:
Private void tb2_manipulationdelta (Object sender, manipulationdeltaeventargs e) {This. pagetitle. Text = "still corresponding event ";}
Effect:
Like the above sentence, the system still responds to the event (it seems that it is nonsense to write this event test :))
Okay, just add this sentence, and add the attribute ishittestvisible = "false" so that it will not respond to the user's touch operation;
In layout, the opacity attribute does not have the visibility attribute. If you need to use frequent layout nesting, try to avoid opacity. If you use the above two attributes in grid and other elements, the elements contained in gird will also apply these two attributes;
If the rendertransform attribute is applied to the panel, the child element in the panel will also be affected. However, if the rendertransform attribute is set in the subpanel, the parent panel will ignore the effect of the Child Panel transformation;