c# - Populate Textbox from Listbox Selection | Windows 7 Phone -


question:

simply, best/most simple way pre-defined items in listbox

(such "bob")

to populated textbox in windows 7 phone enviroment?

example:

if select "bob" list box - "bob" should displayed in text box instantly

(so user doesn't need type in username)

..and can instead use pre-made username list of usernames.

problems:

  • i've tried looking these little things , found no solutions.
  • the solutions did find incredibly vague.
  • many videos on youtube , elsewhere haven't covered windows 7
  • i fear windows 8 mobile different.
  • right now, code fails populate textbox listbox selection.
  • relatively new programmer, trying find feet in c#

code:

i don't know how this. i've tried using built in feature called selectionchanged no success.

your class

public class movie {    public string actor { get; set; }    public string name { get; set; }  } 

create list of movie data .

public class movielist : list<movie> {    public movielist()    {      add(new movie { name = "titanic", actor = "xxx", });      add(new movie { name = "lordoftherings", actor = "yyyy",  });    } } 

in xaml,

<listbox height="596" name="listbox1" width="380" > <listbox.itemtemplate> <datatemplate> <stackpanel orientation="horizontal"> <textblock text="{binding path=name}"></textblock> </stackpanel> </datatemplate> </listbox.itemtemplate> </listbox> 

in code behind.cs

 public mainpage() {    initializecomponent();    filllistbox(); }  private void filllistbox() {    listbox1.itemssource = new movielist(); } 

your textbox should be

<textbox text="{binding elementname=listbox1, path=selectedvalue}"/> 

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 -