2

I want to set the window to an exact size for creating a game, since I will use the X and Y coordinates of the screen to move things. The problem is that when setting the window width and height it includes the border in that size, so your actual size is smaller than what you specify. What can I do about this?

3
  • 2
    Can you set the width and height to the panel inside of the window instead? Usually it's a Grid panel unless you have changed it. You can then set your window's SizeToContent property so it can autosize to fit the Grid. Commented Mar 20, 2013 at 1:50
  • Thanks! It is actually a Canvas, but that worked. Exactly what I was looking for. Commented Mar 20, 2013 at 1:53
  • No worries, that's great! Commented Mar 20, 2013 at 2:19

3 Answers 3

1

You set the width and height to the panel inside of the window instead. Usually it's a Grid panel unless you have changed it. You can then set your window's SizeToContent property so it can autosize to fit the Grid.

Sign up to request clarification or add additional context in comments.

Comments

0

Or you could do like this maybe: myForm.Width = yourValue + borderSize;

Comments

0

If your window is a WPF window try using AllowsTransparency="True" and WindowStyle="None"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.