質問

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