B
B
buydofegni2019-02-05 13:16:09
WPF
buydofegni, 2019-02-05 13:16:09

C# WPF why does Window.Left = 0 appear between screen border and window?

Visual Studio 2017, I create a new project (WPF Application), here is the main window class:

public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            Left = 0;
            Top = 0;
            Height = 1080;
            Width = 1920;
        }
    }

The screen size is 1920x1080, but when the program starts, there are some indents on the right, left and bottom. Where could they come from?
screenshot
5c59622c0ef3f885121130.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
VoidVolker, 2019-02-05
@VoidVolker

It's not padding, it's the window border. The presence of a border and its thickness is set in the window properties or in styles, I don’t remember exactly, because it may be different in different OS versions.

A
Alexey Pavlov, 2019-02-06
@lexxpavlov

This is the chrome of the window (WindowChrome), usually looks like a shadow around the window, is part of the window, on top of the client part. Usually the chrome size is 7px.
https://docs.microsoft.com/en-us/dotnet/api/system...
Chrome is disabled when the window is set to maximized (Maximized). And also, you can specify WindowStyle.None to the window, then the non-client part will be disabled.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question