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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:49:21+00:00 2026-05-15T08:49:21+00:00

In order to handle multiple resolutions I have following controls in the same xaml

  • 0

In order to handle multiple resolutions I have following controls in the same xaml page.

  • Grid -> Viewbox (stretch, centered) -> Canvas (centered) -> Rectangle X (centered)
  • FrameworkElement

I am trying to cover the whole page with a black overlay and cut a rectangle for the Rectangle X in the center of the page.

To create the black overlay I paint the whole page black and then :

        DrawingVisual dv = new DrawingVisual();

        using (DrawingContext dc = dv.RenderOpen())
        {
            double sw = SystemParameters.PrimaryScreenWidth;
            double sh = SystemParameters.PrimaryScreenHeight;
            PathGeometry cmbg = null;

            RectangleGeometry rectangleFullScreen = new RectangleGeometry(new Rect(0, 0, sw, sh));
            cmbg = Geometry.Combine(Geometry.Empty, rectangleFullScreen, GeometryCombineMode.Union, null);

            RectangleGeometry rectangleHole = new RectangleGeometry(holeRectangle);
            cmbg = Geometry.Combine(cmbg, rectangleHole, GeometryCombineMode.Exclude, null);

            Brush b = new SolidColorBrush(Colors.Black);
            b.Opacity = 0.85;
            dc.DrawGeometry(b, new Pen(), cmbg);
        }

        return dv;

In order to calculate the rectangle to exclude I get the screen coordinates of the RectangleX (.PointToScreen(new Point(0, 0));)

And the problem is that if I modify the size of the Viewbox (depending on the Resolution) the RectangleX changes its location but the PointToScreen always returns the same Screen coordinate.

Witout changing the viewbox the hole is cut at the right place, just above the RectangleX.

How can I get the correct coordinate of the RectangleX in order to draw the exclude rectangle?

I would be very grateful for your help.

Thank You

Peter

  • 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-15T08:49:22+00:00Added an answer on May 15, 2026 at 8:49 am

    I have been struggling with this for couple of days now…but found the solution 10 minutes after posting the question…

    ANSWER:

    After changing the width and max width of the Viewbox I have to call UpdateLayout()

    It works now!

    p.

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

Sidebar

Related Questions

In order to handle concurrency issue, is locking-- any form of locking, whether it's
In order to debug an asp.net web app I have to have IE Script
In order to improve my open source project, I need testers. I have created
First of all, I am a complete Java NOOB. I want to handle multiple
My app needs to pull data from MULTIPLE sources. The following needs to be
Is there a better way to handle form tab order in PHP than this?
I am using GAE's Python environment and Janrain in order to provide multiple ways
If multiple instances of a singleton are trying to update the same property simultaneously,
I have a HashSet that contains multiple lists of integers - i.e. HashSet<List<int>> In
What order of precedence are events handled in JavaScript? Here are the events in

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.