c# - Accessing ListBox and other children in a LongListSelector -


i'm building app there's arbitrarily long list of items can click on of them , edit in place. edit of these items want programmatically change focus next item in list.

<grid x:name="contentpanel" grid.row="1" margin="12,0,12,0">     <phone:longlistselector x:name="mainlonglistselector" margin="0,0,-12,0" itemssource="{binding items}" selectionchanged="mainlonglistselector_selectionchanged">         <phone:longlistselector.itemtemplate>             <datatemplate>               <stackpanel margin="0,-10,0,-12">                   <textbox  x:name ="tb" text="{binding thetext}" textwrapping="wrap" textchanged="textbox_textchanged" />               </stackpanel>             </datatemplate>         </phone:longlistselector.itemtemplate>     </phone:longlistselector> </grid> 

as user types in first textbox , text exceeds # of characters (e.g. 138) want either add item list next item , change focus it, or, if there's next item, change focus it.

i can't figure out how access to

1) root list box 2) textbox control within item given list box item id

here's tried. when runs, mainlonglistselector.selecteditem = nextitem causes next item selected, not focus.

private void textbox_textchanged(object sender, textchangedeventargs e) {     var editbox = sender textbox;     var selecteditem = mainlonglistselector.selecteditem itemviewmodel;     if (editbox != null && selecteditem != null && editbox.text.length > 138) {         // move data @ end next box         var overflow = editbox.text.substring(138, editbox.text.length - 138) ;         selecteditem.tweet = editbox.text.substring(0, 138);         var nextitem = app.viewmodel.items[int.parse(selecteditem.id) + 1];         nextitem.tweet = overflow;         mainlonglistselector.selecteditem = nextitem;     } } 

i want able access actual textbox of nextitem can explicitly set focus it.

the same question applies if use listbox issues different. in listbox case when datatemplate contains textbox , focus set, don't selectionchanged events...which why i'm sticking longlistselector.

if understand correctly, want textbox focus when item item selected.

if need, here way bind lisboxitem.isselected element.focus(): http://social.msdn.microsoft.com/forums/en-us/adeb3e7f-16df-4c7b-b2d2-d7cdedb32ac0/setting-focus-of-a-textbox-inside-a-listbox?forum=wpf


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -