简体   繁体   中英

Control to display mix of text and links in wp8

Is there any control in windows phone using which I can handle strings of type:

@user1 commented on @user2's post on #page

Of the above string I want to handle clicks on @user1 , @user2 and #page navigating to local urls like /MainPage.xaml?profile=user1 or /MainPage.xaml?page=pagename

Is there some way to do this?

I was thinking of a bad bad way earlier to divide my message string like:

  • TextBlock1 --> user1
  • TextBlock2 --> commented on
  • TextBlock3 --> user2 etc....

But then I realized its not gonna work. There need to be generic way to do this. I also wish to assign different colors to each of the link if possible.

I can transform my string into something like:

<>user1<> commented on <>@user2's<> post on <>#page<>

with a tags around. Is there some control for this? Can't user WebBrowser control.

Also this is not the only string I wish to handle of this type. String can be any other random text with user and page links in between.

Use RichTextBox control and put inside Hyperlink items:

  <RichTextBox>
    <Paragraph>
      <Hyperlink Click="Hyperlink1_Click">@user1</Hyperlink>
      <Run Text=" commented on " />
      <Hyperlink Click="Hyperlink2_Click">@user2</Hyperlink>
    </Paragraph>
  </RichTextBox>

for the Hyperlink items you can either handle the Click event, or try directly to set a navigation uri that points to a local page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM