Is it possible to add a parent to the UIElement in C#? I know it's possible to do it with children like this:

(AssociatedObject as Grid).Children.Add(imageObject);

I can't find any way to set the parent of a UIElement, and can't find very much on Google either.

有帮助吗?

解决方案

No, it's not. The UIElement class actually doesn't support adding a Parent or Children.

Your example uses the Grid class (which does, in fact, allow you to add children). You'd have to add the child element to the parent element using the parent's children collection (assuming the parent is of a type that allows adding children).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top