Monday, 15 September 2014

Windows Phone UIElementCollection in UserControl -



Windows Phone UIElementCollection in UserControl -

i have uielementcollection in usercontrol custom uielements. uielements not displayed. whats wrong?

public partial class mycontrol : usercontrol { public static readonly dependencyproperty childrenproperty = dependencyproperty.register("children", typeof(uielementcollection), typeof(mycontrol), null); public uielementcollection children { { homecoming (uielementcollection)getvalue(childrenproperty); } set { setvalue(childrenproperty, value); } } protected override size measureoverride(size availablesize) { children.clear(); usercontrol kid = new secondusercontrol(); child.measure(availablesize); children.add(child); } protected override size arrangeoverride(size finalsize) { foreach (uielement kid in children) { child.arrange(new rect(0,0, child.desiredsize.width, child.desiredsize.height)); } homecoming finalsize; } }

oy vey. whatever you're trying do, isn't way it.

first, children colleciton never makes ui. declaring properties , measuring stuff doesn't add together ui. have create sure children part of visual tre adding them on usercontrol.content.

second, why adding , removing children on every measure pass? doesn't create sense usecase. measure & arrange pass isn't time remove/add control, it's time measure , arrange control.

windows-phone-7 windows-phone-8 windows-phone

No comments:

Post a Comment