HandyOrg / HandyOrg/HandyControl

Change SizeToContent in OnLoaded or OnSourceInitialized has no effect

Open
#967 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
7.2k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
hc:Window的继承类,如果在XAML中设定了SizeToContent="WidthAndHeight",在OnLoaded或者 OnSourceInitialized 里面修改SizeToContent为Manual会无效,窗口还是会自动变化。

产生原因:
https://github.com/HandyOrg/HandyControl/blob/4735ebc812a3e4e264cd13865f512e0b360b154d/src/Shared/HandyControl_Shared/Controls/Window/Window.cs#L313

会导致在OnLoaded、OnSourceInitialized 之后SizeToContent更新一次,使得在这两个方法中设置的SizeToContent和窗口Width、Height被覆盖。

解决办法
在XAML中去掉SizeToContent属性设置,或者修改为非WidthAndHeight的值。

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/Shared/HandyControl_Shared/Controls/Window/Window.cs around line 313 and review how SizeToContent is updated during window initialization. Reproduce the issue with SizeToContent="WidthAndHeight" and changes in OnLoaded or OnSourceInitialized. Done means those lifecycle changes are no longer overwritten and the window keeps the intended manual size.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.