在 Silverlight 中删除 UIElement 的父级
我有一个 UIElement
对象,如何删除它的父对象?
我发现 UIElement
的父属性没有设置器。
任何建议都会有帮助。
编辑 :
protected FrameworkElement Content
{
get { return this.content; }
set
{
if ((this.content != null) && (this.Children.Contains(this.content)
== true))
this.Children.Remove(this.content);
this.content = value;
if ((this.content != null) && (this.Children.Contains(this.content)
== false))
{
this.Children.Add(this.content); // here i get error Element is already an child of another
}
this.InvalidateMeasure();
this.InvalidateArrange();
}
}
I have an object of an UIElement
, how can I remove the parent of it?
I saw that there is not setter for parent property of an UIElement
.
Any suggestions will be helpful.
EDIT :
protected FrameworkElement Content
{
get { return this.content; }
set
{
if ((this.content != null) && (this.Children.Contains(this.content)
== true))
this.Children.Remove(this.content);
this.content = value;
if ((this.content != null) && (this.Children.Contains(this.content)
== false))
{
this.Children.Add(this.content); // here i get error Element is already an child of another
}
this.InvalidateMeasure();
this.InvalidateArrange();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
UIElement.Parent
只是将父级返回为一个 UIElement。如果您知道父元素是什么,则可以将其强制转换为正确的元素。假设您有一个父级,这是一个 StackPanelUIElement.Parent
just returns the Parent as aUIElement
. You can cast it to the right element if you know what the parent is. Lets say you have a parent this IS aStackPanel