locked
Mixing HyperlinkButton and TextBlocks in a WrapPanel RRS feed

  • Question

  • Hopefully someone can lend a hand.  I'm trying to get a mix of HyperlinkButtons and TextBlocks to wrap nicely.  I've put them in a WrapPanel from the Silverlight Toolkit and specified TextWrapping="Wrap" for all the text blocks.  What I'm seeing in the browser as a result is the hyperlinks on their own lines when the text blocks surrounding them are longer than a line.  It looks something like:

    texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttext

    link

    moremoremoremoremoremoremoremoremoremoremoremoremoremoremoremoremoremore

    moremoremoremore

     Instead of

    texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttext link moremoremoremoremore

    moremoremoremoremoremoremoremore

    I'm guessing this has to do with the interface for how layout within panels work.  The interface seems to assume rectangularly shaped objects being layed out whereas wrapped text isn't rectangular in shape.  Is there some way to achieve the effect I'm looking for? Note text wrapping is working fine for me when HyperlinkButtons are not involved.  Yes, I've tried setting MaxWidth, but no luck.

    You would think mixing hyperlinks and text would be a common sort of thing for a web app, but it doesn't seem easy to do.  Can someone please help me out?

     

    Sunday, December 14, 2008 7:22 PM

Answers

  •  I'm trying to get a mix of HyperlinkButtons and TextBlocks to wrap nicely. 

     

    Hi,

    i guess what you are looking for is right here

    http://www.silverlightshow.net/items/Silverlight-LinkLabel-control.aspx

    and if the post was helpful then please 'Mark as Answer' - many thanksSmile

    Sharker Khaleed Mahmud
    Software Developer
    (MCP,MCTS,MCPD[web])

    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.

    Sunday, December 14, 2008 10:00 PM

All replies

  •  I'm trying to get a mix of HyperlinkButtons and TextBlocks to wrap nicely. 

     

    Hi,

    i guess what you are looking for is right here

    http://www.silverlightshow.net/items/Silverlight-LinkLabel-control.aspx

    and if the post was helpful then please 'Mark as Answer' - many thanksSmile

    Sharker Khaleed Mahmud
    Software Developer
    (MCP,MCTS,MCPD[web])

    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.

    Sunday, December 14, 2008 10:00 PM
  • Thanks for your excellent response.  This solved the problem perfectly.

    Monday, December 15, 2008 2:05 AM
  • Hi,

    WrapPanel does not support combining multiple TextBlocks in the same line. (That includes combining  TextBlockes with Hyperlinks).

    It has to do with the fact the Silverlight layout system works with rectangular claimed areas and not free-form areas.

    This is the expected behavior from WrapPanel since WrapPanel is a port of the WPF WrapPanel control and we'd like to stay XAML compatible between Silverlight and WPF. Though please feel free to submit this feature request to our codeplex issues and if there's enough user feedback and voting on it, we'll figure out how to help.
    http://www.codeplex.com/Silverlight/WorkItem/Create.aspx

    Unfortunately, I'm not familiar with any specific mechanism in Silverlight that enables the feature you're looking for.
    Have you considered just painting some area of the TextBlock with a blue colour and an underline, catching mouse left button down events and redirecting users appropriately with the HTML bridge?

     Sincerely,  

    Monday, December 15, 2008 5:43 PM
  • Somehow the code at http://www.silverlightshow.net/items/Silverlight-LinkLabel-control.aspx solves this problem and it uses a wrap panel.  I haven't look at the code deeply enough to see how it does it, but it does work.  Mixing text and hyperlinks seems like a common thing people want to do with web based applications so I was pretty surprised it wasn't just dead easy with Silverlight.  I'll create a work item in case that turns out to be helpful.  Thanks for responding.

     

     

    Wednesday, December 24, 2008 12:58 AM