silverlight - How to set wrapping for HyperlinkButton with databound Content/Text? -


i binding collection (rss feed) list box such this:

<listbox margin="0,0,-12,0" itemssource="{binding items}">     <listbox.itemtemplate>         <datatemplate>             <stackpanel margin="0,0,0,17" width="432">                 <hyperlinkbutton content={binding title} navigateuri="{binding link}" />                 <textblock text="{binding description}" />             </stackpanel>         </datatemplate>     </listbox.itemtemplate> </listbox> 

this works great - data displays correctly etc. when changed use text wrapping, title not displaying anymore.

here problematic code.

<listbox margin="0,0,-12,0" itemssource="{binding items}">     <listbox.itemtemplate>         <datatemplate>             <stackpanel margin="0,0,0,17" width="432">                 <hyperlinkbutton navigateuri="{binding link}">                     <textblock text="{binding title}" textwrapping="wrap" />                 </hyperlinkbutton>                 <textblock text="{binding description}" textwrapping="wrap" />             </stackpanel>         </datatemplate>     </listbox.itemtemplate> </listbox> 

i don't think it's "textwrapping" attribute causing issue, since tried without , still did not work. question how work? want display hyperlink wrapped bound text. looks simple thing - yet hard. help?

i having exact same problem , couldn't understand why wasn't working until ran across this blog post mister goodcat. in post said because of optimizations made wp7 in silverlight basic functionality works in normal silverlight not work correctly wp7 silverlight. instead of using suggests modifying style instead.

the easiest way edit default templates still use expression blend make copy of , work there. when you'll see template has text block show content. why using ui element content doesn't work hyperlink button on wp7. if want make text wrap, it's sufficient change textwrapping property on text block.

<style x:key="hyperlinkbuttonwrappingstyle"         targettype="hyperlinkbutton">     <setter property="foreground"             value="{staticresource phoneforegroundbrush}" />     <setter property="background"             value="transparent" />     <setter property="fontsize"             value="{staticresource phonefontsizemedium}" />     <setter property="padding"             value="0" />     <setter property="template">         <setter.value>             <controltemplate targettype="hyperlinkbutton">                 <border background="transparent">                     <visualstatemanager.visualstategroups>                         <visualstategroup x:name="commonstates">                             <visualstate x:name="normal" />                             <visualstate x:name="mouseover" />                             <visualstate x:name="pressed">                                 <storyboard>                                     <doubleanimation duration="0"                                                         to="0.5"                                                         storyboard.targetproperty="opacity"                                                         storyboard.targetname="textelement" />                                 </storyboard>                             </visualstate>                             <visualstate x:name="disabled">                                 <storyboard>                                     <objectanimationusingkeyframes storyboard.targetproperty="foreground"                                                                     storyboard.targetname="textelement">                                         <discreteobjectkeyframe keytime="0"                                                                 value="{staticresource phonedisabledbrush}" />                                     </objectanimationusingkeyframes>                                 </storyboard>                             </visualstate>                         </visualstategroup>                     </visualstatemanager.visualstategroups>                     <border background="{templatebinding background}"                             margin="{staticresource phonehorizontalmargin}"                             padding="{templatebinding padding}">                         <textblock x:name="textelement"                                     horizontalalignment="{templatebinding horizontalcontentalignment}"                                     text="{templatebinding content}"                                     textdecorations="underline"                                     verticalalignment="{templatebinding verticalcontentalignment}"                                     textwrapping="wrap" />                     </border>                 </border>             </controltemplate>         </setter.value>     </setter> </style> 

i suggest reading blog post more information & help.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -