2

Disclamer, this is my first post, so I don't know if I got everything I needed to in here. Please keep that in mind while going though my question.

I have been trying to create a part of my program that will be able to send hyperlinks in messages between users. As part of it, these hyperlinks are saved separately from the body of the message (which is just a string) with a starting position, length, and Uri. I figured out all of the parsing things, but what I cannot figure out is how to display the message with they hyperlinks clickable to the user.

I have tried using an ItemsControl, creating a class that has the text before the hyperlink and the hyperlink info and using something like:

<ItemsControl ItemsSource="{Binding Pairs}">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <TextBlock>
                <Run Text="{Binding Pretext, Mode=OneWay}"/>
                <Hyperlink NavigateUri="{Binding Hyperlink.Url, Mode=OneWay}">
                    <Run Text="{Binding Hyperlink.LinkText, Mode=OneWay}"/>
                </Hyperlink>
            </TextBlock>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

However, I cannot figure out how to make the items run together and not set as separate items, and I don't think that that is possible.

I also have tried to, in the code behind, set a textbox's Inlines to each of the "sections" of the message, similar to this question, however, that requires to be running in the code-behind. I tried to add an InlineCollection to the message, but there is no where to set in in the .xaml file.

So my question is where do I go from here? How do I solve any of these issues? Is there a solution?

Thanks in advance

EDIT:

In case it is unclear, I am trying to display a message (type string) that has a list of hyperlinks (custom object with INT start position, INT length, and a URI). The number of these hyperlinks is not consistent, and I want the message to flow on a webpage.

Community
  • 1
  • 1
  • I am trying to display a message (type string) that has a list of hyperlinks (custom type with start position, length, and URI). The number of these hyperlinks is not consistent, and I want the message to flow on a webpage. Hopefully that helps. – TheNightAngel Jan 04 '17 at 18:23

0 Answers0