0

How I can adjust WPF Hyperlink within GridViewColumn.CellTemplate?

enter image description here


Special thanks to @H.B. !!

Here is the solution

<GridViewColumn   Width="Auto" Header="URL" >
    <GridViewColumn.CellTemplate>
        <DataTemplate>                                   
            <TextBlock  Name="urlToContent" MinWidth="100" Width="Auto">
                <Hyperlink NavigateUri="{Binding Path=URL}" Name="hlkURL"   RequestNavigate="OpenPageRequestNavigate">
                     <TextBlock Text="{Binding Path=URL}"/>  
                </Hyperlink>
             </TextBlock>
         </DataTemplate>
    </GridViewColumn.CellTemplate> </GridViewColumn
3
  • Uhm, you should still use a Run instead of a TextBlock inside the Hyperlink... Commented Jan 26, 2012 at 19:44
  • @H.B. ahh! I see. Can you explan please why it is better? I guess Run is not so heavy, correct? Commented Jan 26, 2012 at 19:47
  • Yes, using a TextBlock will also automatially create an InlineUIContainer because the contents of Hyperlinks are inlines (flow content) and not UI-Elements, TextBlocks and other controls things are "not meant to be there". Commented Jan 26, 2012 at 19:53

2 Answers 2

1

TextBoxes do not support flow content, use a TextBlock.

Sign up to request clarification or add additional context in comments.

Comments

0

As @H.B. says you have to use a TextBlock.

However, you can use a RichTextBox

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.