Repository navigation
[ContentSizer]: Fix the implicit setup issues for the DataTable used. - #20
Open
hoshiizumiya wants to merge 1 commit into
Open
hoshiizumiya wants to merge 1 commit into
hoshiizumiya wants to merge 1 commit into
Conversation
3 of 5 tasks
hoshiizumiya
force-pushed
the
fix/ContentSizer
branch
from
September 20, 2026 18:50
292ff60 to
933e807
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current modifications to
ContentSizeressentially add a mode where it serves only as a drag input surface without directly modifying the target control's dimensions, specifically designed to letDataColumntake over column width calculation.Original Behavior
The original
ContentSizerwas designed to:TargetControlis set, automatically find the nearest parentFrameworkElementduringLoaded.ActualWidth/ActualHeightwhen dragging begins.or:
Therefore, it is a control that "directly modifies FrameworkElement dimensions."
This works well for ordinary panels, content areas, and similar scenarios, but is not suitable for DataTable column widths. DataTable column widths are actually determined by a combination of:
DataColumn.DesiredWidthAuto/Pixel/StarColumnSpacingIf
ContentSizerdirectly setsDataColumn.Widthwhile DataTable re‑Measure/Arrange based onDesiredWidth, two competing layout states are introduced.Change 1: Distinguish Between "Not Set" and "Explicitly Set to null"
Previously:
Now:
The distinction is important.
Previous Semantics
The following two cases could not be distinguished:
Both would automatically find the parent control during
Loaded.Even if DataColumn called:
_columnSizer.TargetControl(nullptr);ContentSizer::OnLoadedwould still reassign it to the nearest parent, usuallyDataColumnitself.As a result, during dragging, ContentSizer would still execute:
Current Semantics
Using
ReadLocalValueallows distinction:UnsetValue: The property was never set; retains the original automatic parent lookup behavior.nullptr: The caller explicitly requests no target; automatic lookup no longer occurs.Therefore, in DataColumn:
_columnSizer.TargetControl(nullptr);now truly takes effect.
Issues Resolved
It prevents ContentSizer from directly setting
DataColumn.Width, primarily fixing:DesiredWidthwhile ContentSizer simultaneously modifiesFrameworkElement.Width, causing headers and rows to use different width sources.Change 2: Continue Manipulation Flow When Target Is Explicitly null
New logic added:
Corresponding changes exist for the vertical direction.
Why Returning true Is Necessary
SizerBase::OnManipulationDeltacontains this control flow:Previously, when
TargetControl == nullptr,ContentSizer::OnDragHorizontalreturnedfalse, causingSizerBaseto prematurely end Manipulation handling.But DataColumn now needs to listen to ContentSizer's:
ManipulationStartedManipulationDeltaManipulationCompletedand then calculate column widths itself.
Therefore, the explicit‑null mode needs to convey:
Hence, returning
true.This allows DataColumn to receive events here:
DataColumn.cpp
DataColumn then converts accumulated mouse displacement into a true Pixel
DesiredWidth, and DataTable uniformly arranges headers and rows.Current Three Behaviors
TargetControlStateUnsetValueWidth/Height; behavior unchanged from originalnullptrDataTable uses the third mode.
What It Does Not Handle
The modifications to ContentSizer themselves do not handle:
ActualColumnWidth.GridLengthHelper::FromPixels.These are all handled by DataColumn/DataTable.
ContentSizer handles only one thing:
Impact on the General ContentSizer API
This does change a previously ill‑defined API behavior:
Previously:
meant "please automatically find the parent element."
Now:
means "explicitly do NOT use a target control."
"Automatically find the parent element" now corresponds only to leaving
TargetControlentirely unset.General usage remains unchanged, but code that relied on "explicitly set null first and still auto‑find parent after Loaded" may be affected.
There is also one limitation: this explicit‑null mode currently primarily serves pointer‑based Manipulation. The keyboard adjustment in SizerBase directly calls
OnDragHorizontal/Vertical, which does not generate theManipulationDeltathat DataColumn currently listens for, so DataColumn's keyboard‑based column width adjustments will not take effect through this path. For a complete control‑level solution, it would be best to later add a formalDragDeltaevent to SizerBase/ContentSizer, rather than usingManipulationDeltaas a notification interface.