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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -