c# - passing RSS binded data to another page, windows phone 7 -


this may seem easy answer someone, i'm giving shot i've doubled on trying solve this.

i'm passing rss information listbox itemtemplate binded data. each listboxitem has image url. want user able click on listboxitem, pass image url new page, , open page displaying image.

only problem? cannot work.

here have far:

page1 xaml:

       <listbox x:name="listbox" grid.row="1" selectionchanged="listbox_selectionchanged">             <listbox.itemtemplate>                 <datatemplate>                     <grid>                         <grid.rowdefinitions>                             <rowdefinition height="auto" />                         </grid.rowdefinitions>                         <image grid.row="0" horizontalalignment="left" height="60" width="60" source="{binding url}"/>                      </grid>                 </datatemplate>             </listbox.itemtemplate>         </listbox> 

page1 cs

    private void listbox_selectionchanged(object sender, selectionchangedeventargs e)     {         var urlname = "";          urlname = (sender rssitem).url.tostring();      navigationservice.navigate(new uri("/submittedpic.xaml?image=" + urlname, urikind.relative));     this.listbox.selecteditem = (sender listboxitem);      } 

the code breaking on urlname = (sender rssitem).url.tostring(); , saying null reference exception unhandled.

any on more appreciated.

from code think you're confusing listboxitem , bound object rssitem. if you're binding correctly, rssitem type of object contained in listboxitem.datacontext.

to check this, use debugger see type , value sender is.

the following code works in case: takes sender , gets datacontext, , casts type of bound object.

frameworkelement fe = (frameworkelement)sender; rssitem rssitem = (rssitem) fe.datacontext; string url = rssitem.url.tostring(); 

also, note using selectionchanged in way introduce subtle bugs in touch selection , when back-navigating list details page. avoid these should use tap-event on list item.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -