c# - XAML:Specified element is already the logical child of another element. Disconnect it first -
i building custom modal box in wpf this i want users add modal children control element xaml using custom modal element. since cannot create child window inside main window. doing indirectly using xaml , c#. here sample code implementing modal mainwindow.xaml <local:modalwindow> <border background="red" width="400" height="400"> <button width="110"></button> </border> </local:modalwindow> mainwindow.xaml.cs class modalwindow : stackpanel { public modalwindow() { stackpanel mygrid = this; this.height = 400; this.width = 400; window mywindow = new mywindow(this); } class mywindow : window { public mywindow(object x) : base() { this.windowstate = windowstate.maximized; this.allowstransparency = true; this.windowstyle = windowstyle.none; this.opacity = 0.7; this.background...