Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1049835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:40:42+00:00 2026-05-16T16:40:42+00:00

I have WPF window with a FlowDocument with several hyperlinks in it: <FlowDocumentScrollViewer> <FlowDocument

  • 0

I have WPF window with a FlowDocument with several hyperlinks in it:

<FlowDocumentScrollViewer>
  <FlowDocument TextAlignment="Left" >
     <Paragraph>Some text here
       <Hyperlink Click="Hyperlink_Click">open form</Hyperlink>
     </Paragraph>           
  </FlowDocument>
</FlowDocumentScrollViewer>

In the C# code I handle Click event to create and show a new WPF Window:

private void Hyperlink_Click(object sender, RoutedEventArgs e)
{
    if (sender is Hyperlink)
    {
        var wnd = new SomeWindow();
        //wnd.Left = ???
        //wnd.Top = ???
        wnd.Show();
    }
}

I need this window to appear next to hyperlink’s actual position. So I assume it requires assigning values to the window’s Left and Top properties. But I have no idea how to obtain hyperlink position.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:40:43+00:00Added an answer on May 16, 2026 at 4:40 pm

    You can use ContentStart or ContentEnd to get a TextPointer for the start or end of the hyperlink and then call GetCharacterRect to get the bounding box relative to the FlowDocumentScrollViewer. If you get a reference to the FlowDocumentScrollViewer, you can use PointToScreen to convert it to screen coordinates.

    private void Hyperlink_Click(object sender, RoutedEventArgs e)
    {
        var hyperlink = sender as Hyperlink;
        if (hyperlink != null)
        {
            var rect = hyperlink.ContentStart.GetCharacterRect(
                LogicalDirection.Forward);
            var viewer = FindAncestor(hyperlink);
            if (viewer != null)
            {
                var screenLocation = viewer.PointToScreen(rect.Location);
    
                var wnd = new Window();
                wnd.WindowStartupLocation = WindowStartupLocation.Manual;
                wnd.Top = screenLocation.Y;
                wnd.Left = screenLocation.X;
                wnd.Show();
            }
        }
    }
    
    private static FrameworkElement FindAncestor(object element)
    {
        while(element is FrameworkContentElement)
        {
            element = ((FrameworkContentElement)element).Parent;
        }
        return element as FrameworkElement;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF window( using c# as code behind) that has some text
I have a FlowDocument in a standard WPF application window where I have some
we have a wpf-window with some textboxes and a datagrid. the textboxes descripe a
I have a WPF Window that open a modal child window to load some
I have a WPF Window with WindowStyle set to none. Is there some way
I have a WPF Window defined in XAML like this: <Window x:Class=com.some.company.window xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
I have a WPF window with a text box. I'd like to detect when
I have WPF window with several textboxes, buttons, and canvas where I draw a
I have a WPF window with some textboxes, comboboxes and a grid using MVVM
I have a WPF window, which contains a button called Cancel. Under ordinary circumstances

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.