Cloning iOSLayoutConstraint

I might be overthinking this let me know of the better way of doing it.

I have a View with a segment control that is controlling visibility of 3 container controls. If I set them up in Form Editor I end up with two children containers. I don’t see a way to programmatically remove them from container 1.

So, I was thinking that at runtime I’d iterate through the LayoutConstraints of container1 and make Container2 and container3 the same.

Is there a better way of doing all this? I like the idea of Auto Layout but it makes this sort of stuff a pain to do.

This is how I would do it

Place the first container and set the auto-layout constraints
Place the second container relative to Container1.Top, Width, Height constraints with 0 offset and Container1.Left constraint with a -400 offset
Place third container relative to Container1.Top, Width, Height constraints with 0 offset and Container1.Left constraint with a +400 offset

In the layout editor you will end up with the iPhone having one container in the view, and one container on each sides.

Set a name for Container2.Left constraint, and Container3.Left constraint

Then in the View.Open event

me.Constraint("Container2_Left").Offset=0 me.Constraint("Container3_Left").Offset=0

Thanks! Your solution is much simpler!