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

I wrote the following snippet in order to handle errors. (Page.php gets included in
I have multiple superposed controls which can handle a mouse click under certain conditions.
I have a following SQL table with data ProductList id order productname 79 1
I was searching a way to use nine-patch images in order to handle multiple
I am using Autofac to handle dependency injection in my application. In order not
I am trying to handle a contenteditable body in an iframe, in order to
I've implemented a custom UIButton and in order for me to handle LongPress events
Order by descending is not working on LINQ to Entity In the following Query
Order deny,allow deny from all allow from xx.xx.x.xx RewriteRule . - [F] I have
First of all, I am a complete Java NOOB. I want to handle multiple

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.