指定的Visual已经是另一个Visual的子级或CompositionTarget的根. [英] Specified Visual is already a child of another Visual or the root of a CompositionTarget.

查看:940
本文介绍了指定的Visual已经是另一个Visual的子级或CompositionTarget的根.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我需要打印一个自定义控件,该控件在带有页眉和页脚的页面中使用.当我尝试将自定义控件添加为可视化流程文档时,如果出现以下错误:

指定的Visual已经是另一个Visual的子级,或者是CompositionTarget的根.


请帮帮我.

谢谢,
Siva.

Hello,

I have a requirement to print a customized control which is used in a page with header and footer. When I tried to add the customized control as a visual to flow document, if is giving the error as the following:

Specified Visual is already a child of another Visual or the root of a CompositionTarget.


Please help me.

Thanks,
Siva.

推荐答案

会出现此问题,因为您使用同一视口两次或多次.如果情况是这样,首先应通过调用方法"clearViewport()"来清除视口,然后再检查其是否为空.
如果视口为null,则将子级添加到该视口,否则返回.
这是清除视口的方法.
私有void ClearViewPort()
{
ModelVisual3D viewPortChildLocal;
for(int i = viewport.Children.Count-1; i> = 0; i--)
{
viewPortChildLocal =(ModelVisual3D)viewport.Children [i];
如果(viewPortChildLocal.Content是DirectionalLight == false)
{
viewport.Children.RemoveAt(i);
}
用于检查视口是否为空

ModelVisual3D visual =新的ModelVisual3D();

ClearViewPort(); //首先清除
if(visual!= null)//并且需要检查它是否为空
{
viewport.Children.Add(visual);
}
其他
{
返回;
}
This problem will raise because of you are using the same viewport twice or more than once. if the situation is like that first you should clear the viewport by calling the method "clearViewport()",what you are loading then check whether it is null or not.
if the viewport is null then add the childrens to that viewport else return.
this is the method for clearing the viewport.
private void ClearViewPort()
{
ModelVisual3D viewPortChildLocal;
for (int i = viewport.Children.Count - 1; i >= 0; i--)
{
viewPortChildLocal = (ModelVisual3D)viewport.Children[i];
if (viewPortChildLocal.Content is DirectionalLight == false)
{
viewport.Children.RemoveAt(i);
}
for checking the viewport if it is null or not

ModelVisual3D visual = new ModelVisual3D();

ClearViewPort(); // first clear
if (visual != null) // and need to check if it is null or not
{
viewport.Children.Add(visual);
}
else
{
return;
}


这篇关于指定的Visual已经是另一个Visual的子级或CompositionTarget的根.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆