窗口导航中的问题 [英] Problem in window navigation
问题描述
您好,
我正在设计wpf应用程序,我正试图通过此代码从登录屏幕导航到主屏幕...我在那部分成功...我的问题是之后单击主屏幕中的注销按钮我想再次显示登录页面...我在该部分也是成功的...但是再次登录页面后我用户尝试重新登录我收到如下错误...
错误:
Hello,
I am desiging wpf application and I am trying to navigate from Login screen to Home Screen by this code...I am successful in that part... My problem is that after clicking Logout button in home screen I want to Show again Login Page... I am successful in that part also... But after coming again to login page and i the user tries to relogin I am getting an error as below...
Error :"
Specified element is already the logical child of another element. Disconnect it first.
Views.Home winHome = new Views.Home();
object tmpwinHome= null ;
tmpwinHome= winHome.Content;
winHome.Content = null;
foreach (Window window in Application.Current.Windows)
{
if (window.GetType() == typeof(Login1))
{
(window as Login1).Content = new ContentControl() { Content = tmpwinHome};
}
}
推荐答案
我在线阅读的一个解释是
One explanation I read on-line is
如果element是Panel的子项(例如Grid),则必须将其从Panel的Children集合中删除。如果将其设置为ContentControl的内容,则必须将该Content设置为null(或其他任何非元素的内容)。
If element is the child of a Panel (e.g. Grid) you have to remove it from the Panel's Children collection. If it is set as Content of a ContentControl, you'd have to set that Content to null (or anything else that is not element).
这是一个可能对您有所帮助的链接:
[ WPF错误]
在线更多相同的问题:
[指定的元素已经另一个元素的逻辑子女]
[指定的元素已经是逻辑子元素另一个元素。首先断开连接。]
[指定的元素已经是另一个元素的逻辑子元素。首先断开连接]
我希望这些链接能为您提供帮助。
Here is a link that might help you:
[WPF Error]
Some more of the same questions on-line:
[Specified element is already the logical child of another element]
[Specified element is already the logical child of another element. Disconnect it first.]
[Specified element is already the logical child of another element. Disconnect it first]
I hope that these links will help you.
这篇关于窗口导航中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!