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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:03:19+00:00 2026-05-13T11:03:19+00:00

I want to position a modal dialog (progress window) at the top right corner

  • 0

I want to position a modal dialog (progress window) at the top right corner of the parent window client area.

This code will put it in the corner of the non-client area, but how do I calculate the offset to the client area?

this.Owner=owner;
this.Left=owner.Left+owner.ActualWidth-Width;
this.Top=owner.Top;

Edit:

I found this ‘solution’ that works for normal windows:

this.Left=owner.Left+owner.ActualWidth-Width-SystemParameters.ResizeFrameVerticalBorderWidth;
this.Top=owner.Top+SystemParameters.ResizeFrameHorizontalBorderHeight+SystemParameters.WindowCaptionHeight;

This would however fail for windows that have customized borders.

EDIT:

The code should work regardless of the systems DPI setting (e.g. 120 instead of 96).

  • 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-13T11:03:20+00:00Added an answer on May 13, 2026 at 11:03 am

    As long as your window content is a subclass of UIElement (which is normally the case), you can simply check the area covered by the Content:

    Matrix scaling = PresentationSource.FromVisual(windowContent)
                       .CompositionTarget.TransformFromDevice;
    
    UIElement windowContent = owner.Content as UIElement;
    
    Point upperRightRelativeToContent = new Point(
      windowContent.RenderSize.Width + owner.Margin.Right,
      -owner.Margin.Top);
    
    Point upperRightRelativeToScreen =
      windowContent.PointToScreen(upperRightRelativeToContent);
    
    Point upperRightScaled =
      scaling.Transform(upperRightRelativeToScreen);
    
    this.Owner = owner;
    this.Left = upperRightScaled.X - this.Width;
    this.Top = upperRightScaled.Y;
    

    If you have a strange situation where you want this to work for arbitrary Window.Content, you’ll have to search the window’s visual tree using VisualTreeHelper.GetChildCount() and VisualTreeHelper.GetChild() until you come to a ContentPresenter whose Content property matches that of the Window, and use its first visual child as “windowContent” in the above code.

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

Sidebar

Related Questions

I want to position Dojo's Dijit Dialog relative to one of my html element.
I want to position divs on top of one another. I have created a
I'm trying to make a modal dialog in the least amount of jQuery code
I want to have a dialog that looks kinda like this: I thought this
I have this code for a JQuery a dialog for a div containing a
I want to vertically center a modal. If the window height is sufficient to
I have the following link which opens a jquery modal window: <div id='confirm-dialog'><a href='#'
I want to position a comments container relative to the post container . But
I want to position two ImageViews horizontally, but I am not able to get
I want to position a DIV 200 pixels to left of the center. I

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.