c# - How to find a button by name -
so, have 2 buttons in xaml:
<button x:name="but1" /> <button click="button_click" tag="but1" />
and want fiind first button when second button pressed , add listbox this:
private void button_click(object sender, routedeventargs e) { //this how imagine string buttonname = (sender button).tag.tostring(); button findedbutton = find(buttonname); listbox1.items.add(findedbutton); }
you can try this. layout root overall layout inside layout want find item name return object , have check if button found looking for.
object item = layoutroot.findname(buttonname); if(item button) { button btn=(button)item; }
Comments
Post a Comment