silverlight - Finding a UIElement's true position when within a PivotItem -
i'd on-screen position , visibility of textblock
embedded in pivotitem
- e.g. on-screen position , visibility of tb2
in:
<phone:pivot> <phone:pivotitem header="first"> <textblock x:name="tb1" text="hello 1"></textblock> </phone:pivotitem> <phone:pivotitem header="second" > <textblock x:name="tb2" text="hello 2"></textblock> </phone:pivotitem> <phone:pivotitem header="three" > <textblock x:name="tb3" text="hello 3"></textblock> </phone:pivotitem> </phone:pivot>
for other xaml controls have achieved using code like:
public static rect position(this frameworkelement element) { if (element.visibility == visibility.collapsed) return rect.empty; if (element.opacity < 0.01) return rect.empty; // obtain transform information based off root element generaltransform gt = element.transformtovisual(application.current.rootvisual); // find 4 corners of element point topleft = gt.transform(new point(0, 0)); point topright = gt.transform(new point(element.rendersize.width, 0)); point bottomleft = gt.transform(new point(0, element.rendersize.height)); point bottomright = gt.transform(new point(element.rendersize.width, element.rendersize.height)); var left = math.min(math.min(math.min(topleft.x, topright.x), bottomleft.x), bottomright.x); var top = math.min(math.min(math.min(topleft.y, topright.y), bottomleft.y), bottomright.y); var position = new rect(left, top, element.actualwidth, element.actualheight); return position; }
however, pivotitem
children calculation doesn't provide expected answers when pivotitem
off-screen. instead provides answer of position item take on-screen when pivotitem
swiped on-screen. during transition, can see position correctly calculated using above method - e.g. during transition see position correctly swipe in left/right of screen.
i've looked through other properties visible
, opacity
see if there other mechanism being used here hide off-screen pivotitem or 1 of parent
, grandparent
, etc - of seem yield visible
, opacity == 1.0
results.
i've tried iterating visualtree see if element solid background masking "off-screen" pivotitem
s - can't see in tree.
is there other property consider here? how pivotitem
contents hidden when "off-screen"? if have to, know can use selectedindex
property of pivot
try pivotitem
position calculations, i'm hoping avoid selectedindex
if can - i'd prefer position using general xaml , visualtree methods if @ possible.
i looked it, can't find how hiding pivotitems. guess position correct, item not drawn unknown (to me) reasons. i'll again, later, wanted mention few other potential issues noticed.
shouldn't using math.max bottom right corner? reason being - actualheight , actualwidth not rotation-aware speak.
rendersize.width/height , actualwidth/height different. i'm not sure it's idea use both of them calculation.
don't need check in visual tree above element see if it's visible?
edit: looked @ microsoft.phone.dll's decompiled source (that's dll pivot control), , couldn't find how pivotitems hidden. there native method calls though.
Comments
Post a Comment