Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Such as title, would like to do with WPF Windows program page switching, the method used is:
After new a user control, first to Clear and then Add.

Method approximately as follows:
C#
System_Function.System_Function_Button SFB = new System_Function_Button();
system_function1_panel1.Children.Clear();
system_function1_panel1.Children.Add(SFB);


But after several switch pages (with the button repeatedly triggered Clear and Add) after an error, the screen that appears as follows:
http://i.imgur.com/N141GDB.png[^]

Windows will crash, solving ~
Posted
Updated 3-Jun-14 22:19pm
v2
Comments
Richard MacCutchan 4-Jun-14 4:25am    
Your system_function1_panel1 reference is getting corrupted or destroyed somewhere. And with those cross references between controls it is little wonder. You need to use your debugger to find out where.
johannesnestler 4-Jun-14 11:05am    
check if your System_function1_panel1 is null before trying to add to ist children. But such code "smells" - better redesign your control handling - Looks you are cross referencing controls - try to build better encapsulation.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900