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

Is there any way to stop the callout from automatically appearing on an embedded
Is there any way to stop IB in XCode 4 from zooming to try
Is there any way to stop OpenCL kernel from execution? For example, I launch
Is there any way to stop PowerShell from removing console message colors when using
Is there any way to stop the execution of a matlab program from the
Is there any way to stop a .NET console app from being closed? I've
My doubt is, is there any way to stop the looping selector from looping
Is there any way to stop Firefox from submitting a form on a Javascript
Is there any way to stop the page from loading the next page when
Is there any way to stop animation in iOS 3 ? I know about:

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.