title: Silverlight: make a hyperlink button appear like a textblock?
body: <p>I'm trying to make all the words in textblock that are URIs clickable. Here is the approach I've taken:</p>
  
  <pre><code>    private static void onTextChanged(DependencyObject dependObj, DependencyPropertyChangedEventArgs e)
      {
          WrapPanel wrapPanel = ((HyperlinkTextBlock)dependObj).LayoutRoot;
          wrapPanel.Children.Clear();
  
          // TODO: use a real wordbreaker?
          // adding an extra space to the end of the last word. Cry.
          IList&lt;string&gt; words = ((string)e.NewValue).Split(' ').Select(word =&gt; word + " ").ToList();
          foreach (string word in words)
          {
              Uri uri;
              if (Uri.TryCreate(word, UriKind.Absolute, out uri))
              {
                  // TODO the style is off - the text is too big
                  wrapPanel.Children.Add(new HyperlinkButton()
                  {
                      Content = word,
                      NavigateUri = uri,
                      TargetName = "_blank",
                      Margin = new Thickness(0),
                      Padding = new Thickness(0),
                  });
              }
              else
              {
                  wrapPanel.Children.Add(new TextBlock() { Text = word, TextWrapping = TextWrapping.Wrap });
              }
          }
      }
  </code></pre>
  
  <p>(I'd be totally up for a more XAML-oriented/declarative way of doing this, but I'm not sure how I'd go about doing that.)</p>
  
  <p>This works fine (except it'd be nice to use a real wordbreaker), except that the <code>HyperlinkButton</code> looks funny. It is too large, and the text won't wrap. It also seems to have some offset, which I've tried to fix through setting the <code>Margin</code> and <code>Padding</code> to 0, but it hasn't solved the problem.</p>
  
  <p>Any other ideas? Really, I want <code>HyperlinkText</code> instead of <code>HyperlinkButton</code>, but I don't think that Silverlight 3 for the Windows Phone 7 offers that. </p>