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 3693040
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:19:53+00:00 2026-05-19T04:19:53+00:00

Is there any way to stop a WPF Popup from repositioning itself when it

  • 0

Is there any way to stop a WPF Popup from repositioning itself when it goes off-screen?

I found this old question, but it didn’t get a proper answer to it. Is there any way to do this? I’m willing to subclass it if necessary. Thanks.

  • 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-19T04:19:54+00:00Added an answer on May 19, 2026 at 4:19 am

    As Andrei points out, this behavior is deep inside the Popup control and hard to overcome. If you are willing to do some work it can be done by resizing and translating the content of the popup when it reaches the screen edges. For the purposes of the demonstration, we’ll focus on the left edge of the screen.

    If we have some XAML like this:

    <Window ...
            LocationChanged="Window_LocationChanged"
            SizeChanged="Window_SizeChanged"
            >
        <Grid>
            <Rectangle Name="rectangle1" Width="100" Height="100" Fill="Blue"/>
            <Popup Name="popup1" PlacementTarget="{Binding ElementName=rectangle1}" IsOpen="True" Width="100" Height="100">
                <TextBlock Background="White" TextWrapping="Wrap" Width="100" Height="100">
                    <TextBlock.Text>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</TextBlock.Text>
                </TextBlock>
            </Popup>
        </Grid>
    </Window>
    

    and code-behind like this:

    private void Window_LocationChanged(object sender, EventArgs e)
    {
        RefreshPopupPosition();
    }
    
    private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
    {
        RefreshPopupPosition();
    }
    
    private void RefreshPopupPosition()
    {
        var upperLeft = rectangle1.PointToScreen(new Point(0, 100));
        var xOffset = Math.Min(0, upperLeft.X);
        popup1.Width = xOffset + 100;
        (popup1.Child as FrameworkElement).Margin = new Thickness(xOffset, 0, 0, 0);
        popup1.HorizontalOffset += 1;
        popup1.HorizontalOffset -= 1;
    }
    

    then by calculating that the Popup would be off-screen, we can reduce the width of the content and give it a negative margin so that the portion that is on-screen is clipped to what would have appeared if the Popup were to allow this.

    This would have to be extended to deal with all four edges of the screen and the possibility of multiple screens, but it demonstrates that the approach is workable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There doesn't seem to be any tried and true set of best practices to
Is there a way to test if a collection is already initialized? try-catch only?
This is beyond both making sense and my control. That being said here is
If all tables I want to delete from have the column gamer_id can i
I am attempting to pull some information from my tnsnames file using regex. I
I've found several jQuery syntaxes for nullifying the enter on a form. First one:
I'm using the people picker so the user can choose a phone number from
Well i have the following table(info from pgAdmin): CREATE TABLE comments_lemms ( comment_id integer,
I'm trying to build a C++ extension for python using swig. I've followed the
I would like to remove/delete a migration file. How would I go about doing

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.