c# - Select XAML TextBox in StackPanel using TextBox's Index -
i have following code:
//all elements edited below have been defined in mainpage.xaml int index = window_1_document_page_1.children.indexof(sender textbox); //window_1_document_page_1.focus(focusstate.programmatic); window_1_document_page_1.children.remove(sender textbox);
before deleting sender textbox
, how set focus textbox above it?
thanks in advance.
maybe there more elegant solution, should work:
//get index of control want delete int index = panel.children.indexof(sender textbox); //find textbox lower index var control = panel.children.lastordefault(c => c textbox && panel.children.indexof(c) < index); //check if control found if (control != null) { //set focus var textbox = control textbox; textbox.focus(focusstate.programmatic); } panel.children.remove(sender textbox);
Comments
Post a Comment