xaml - Can't remove runtime generated control in WPF -


i can't seem remove button have been generated during runtime.

here's code generates button:

void testarea(object s, routedeventargs e)     {         system.windows.controls.button mybutton = new system.windows.controls.button();         mybutton.name = "runtimegeneratedbutton";         mybutton.content = "deleteme";         mybutton.click+= new routedeventhandler(deleter);         operationspannel.children.add(mybutton);     } 

and here's code supposed remove generated button:

private void deleter(object s, routedeventargs args)     {         operationspannel.children.remove(operationspannel.findname("runtimegeneratedbutton") system.windows.controls.button);     } 

for controls create in code, if want find them name, need registername in current name scope:

operationspannel.children.add(mybutton); operationspannel.registername("runtimegeneratedbutton", mybutton); 

this done automatically xaml parser


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -