【发布时间】:2010-10-20 18:26:26
【问题描述】:
所以对于我的应用程序,我只加载了一个图像,然后在一个选项卡项的网格中。单击按钮后,我创建了一个带有关联代码的新选项卡项以加载其他内容。但是,在返回第一个选项卡时,我遇到了这个错误:
“在附加到新的父 Visual 之前,必须断开指定子与当前父 Visual 的连接。”
具体来说:
public class VisualsHost : FrameworkElement
{
DrawingVisual _square;
public VisualsHost()
{
_square = new DrawingVisual();
this.Loaded += new RoutedEventHandler(OnLoaded);
}
public void OnLoaded(object sender, RoutedEventArgs e)
{
AddVisualChild(_square);
AddLogicalChild(_square);
}
这只是我在主选项卡中用于我的内容的选择方块的容器。
所以我想知道,这里到底发生了什么,我将如何解决这个问题?
我的第一个标签中的内容的简要结构是:
tabcontrol> 停靠面板 ->listbox -> 网格(itemspanelcontainer 样式) -> listboxitems...
【问题讨论】:
标签: wpf