简体   繁体   中英

C# Silverlight move a control

Is it possible to change the parent of a silverlight control? When I tried adding it to the children collection I got an exception.

You cannot assign a control to two different parents, which is probably the error you're seeing. You need to remove the control from it's existing parent before you try and add it to the new parent.

I don't have a compiler on me, but I'd assume the syntax would be something like this:

MyStackPanel1.Children.Remove(SomeControl);
MyStackPanel2.Children.Add(SomeControl);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM