Using WPF Popup Controls with Hyperlink and TextBlock

In this post I am going to describe how you can use WPF popup control with Hyperlink. Instead of showing the content with in Popup Control, we can use common Tool Tips as we can easily bind any WPF element within Tool Tips. But there are few advantages of Popup controls over default Tool tips where we can think to use Popup instead of Tool tips.

First of all, You must have to set IsOpen=True to Popup control to appear. Unlike ToolTips, Popup control never visible by default. Secondly, Tool Tips disappears automatically after a certain time, but for Popup Control you have to explicitly set StayOpen property to true or false.

Read more about WPF Popup Control .

Below image shown as example, where on mouse of underline text a popup appears with some details information.


To achieve this, first create a WPF Sample Application with TextBlock with main content  and a Popup Control with the content which will display the more information for the underlined text.

Below is the used code snippet for the XAML.

<Window x:Class="PopupWPF.MainWindow"
        Title="WPF Popup With Hyperlink" Height="189" Width="525">
        <TextBlock TextWrapping="Wrap">A single tip can improve productivity of work while coding.
            <Run Cursor="Hand" TextDecorations="underline" MouseEnter="Run_MouseEnter_1"> Daily .NET Tips</Run>
            is aiming to sharing useful coding tips and tricks for .NET Developers. This site completely design for sharing Tips and Tricks, 
            useful Code Snippet which anyone use in daily development work and targeted anything related with .NET.
        <Popup Name="DDNTPopup"
               PopupAnimation="Slide" >
            <Border BorderBrush="Beige" 
                <TextBlock Margin="10" 
                           TextWrapping="Wrap" >
                   Visit <Hyperlink NavigateUri="" Click="Hyperlink_Click"></Hyperlink>
                    for more information. Daily .NET Tips has now more than 170 very useful tips and Tricks. To keep update on daily tips,  
                    <Hyperlink NavigateUri="" Click="Hyperlink_Click_1">subscribe</Hyperlink> our feed or follow us on
                    Twitter at  <Hyperlink NavigateUri="!/dailydotnettips" Click="Hyperlink_Click_2">@dailydotnettips</Hyperlink>

I have used Run element to apply the formatting on text and providing a Event Handler.


On Mouse enter, we need to make the Popup Visible, so below is the code snippet for the display the popup.


We are not explicitly handling the close event of Popup control here, because in XAML we have already mentioned StaysOpen=”False”, which means, Popup will automatically disappear if user click some where else.



The only think left here is handling the Click="Hyperlink_Click" event. Below is the code snippets for the same.


That’s all !

Hope this will help

Cheers !


Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.