dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.03k stars 1.16k forks source link

The WPF window doesn't look the same in designer as it does when built #9725

Open Grey-Wind opened 1 week ago

Grey-Wind commented 1 week ago

Description

The WPF window does not look the same in design mode as it does when built.

The window style is SingleBorderWindowor ThreeDBorderWindow.

I don't know if this will be a problem in ToolWindowstyle

Reproduction Steps

Create a WPF project and build.

You can add a test label.

Expected behavior

The contents on the right and bottom are displayed completely.

Actual behavior

The content on the right and below is incomplete or cropped.

Regression?

I didn't test the older version.

Known Workarounds

Use the None window style.

Impact

No response

Configuration

.net6 to .net8

windows10 22h2

any cpu

Other information

Video_CN

Video_EN

The project in the video is .net8

miloush commented 1 week ago

As far as I can see everything seems to be working as expected. The Width and Height properties on Window include the borders and caption/title bar. That's why None window style meets your expectations, because the content area is not decreased by them. When you set the same dimensions on the child, it does not fit the window and will be cropped, exactly how the designer shows you. You can use SizeToContent=true to resize the window automatically to fit all of the content.

Are you simply trying to align the label to the right bottom corner? Why use the Margin instead of the HorizontalAlignment and VerticalAlignment?

Grey-Wind commented 1 week ago

I am used to using margin in my daily life. Since there is no need to develop very large software, margin does not affect normal development except for this display problem.