Result DataGrids: main column does not fill remaining width until window resize
Background
The DNSLookupView originally rendered the Result column at its MinWidth and only filled the remaining width after the user resized the window. Root cause is a known WPF behaviour: when a DataGrid is initially empty and HorizontalScrollBarVisibility="Auto" (default), the inner ScrollViewer measures with infinite width. Star-sized columns (Width="*") then collapse to their MinWidth. A re-measure is only triggered by a window resize — adding rows alone is not enough.
The fix in DNSLookupView was:
- Last (or otherwise designated) column gets
Width="*" while all earlier columns keep MinWidth only.
HorizontalScrollBarVisibility stays at the default (Auto) so the horizontal scrollbar still appears when the sum of MinWidth values exceeds the viewport.
- A one-shot
LoadingRow handler in code-behind resets star columns once on the first rendered row, forcing the recompute. The handler unsubscribes itself.
Reference files:
Source/NETworkManager/Views/DNSLookupView.xaml — column definition with Width="*", LoadingRow wired up.
Source/NETworkManager/Views/DNSLookupView.xaml.cs — DataGridResults_LoadingRow handler. Includes using System.Windows.Threading; for DispatcherPriority.
Goal
Apply the same pattern to other result-style views so their main "content" column fills the remaining width on first paint and the scrollbar still appears when the window is too narrow. Decide per view whether enabling TextWrapping="Wrap" on the star column is desirable.
Views to audit
Result views (start empty, populated by user action) — primary candidates:
Possibly affected (auto-load on view open, but the bug can still bite if first load is async):
Not in scope (data is configured, so the DataGrid usually has content right at first measure):
AboutView.xaml (already uses Width="*", works because data is synchronous on load)
- All
*SettingsView.xaml (DNSLookup, IPScanner, PortScanner, SNMP, SNTP)
ProfilesView.xaml, SettingsProfilesView.xaml
- Child windows (
PortProfilesChildWindow, SNMPOIDProfilesChildWindow, ServerConnectionInfoProfileChildWindow)
If during the audit one of these turns out to also start empty, apply the fix there too.
Per-view steps
For each view in scope:
- Identify the "main" column. Usually the rightmost, content-heavy column (e.g.,
Hostname, Status, Result, Description). For columns where text length varies a lot, this is the right star candidate. Avoid putting Width="*" on numeric/short fixed-shape columns (TTL, Port, Class).
- Set
Width="*" on that column, keep MinWidth as is. Ensure all other columns keep MinWidth (no Width="*") so the horizontal scrollbar can do its job when the window narrows.
- Decide on
TextWrapping case by case:
- Apply
TextBlock.TextWrapping="Wrap" via <DataGridTextColumn.ElementStyle> only if the column carries variable-length, prose-like content (descriptions, error messages, multi-value DNS results).
- Skip wrapping for columns that should stay single-line for scannability (IP addresses, hostnames, statuses, timestamps).
- Wire the
LoadingRow handler following the DNSLookupView template:
- Add
x:Name="..." to the DataGrid/MultiSelectDataGrid if it doesn't have one.
- Add
LoadingRow="<Name>_LoadingRow" to the XAML element.
- Implement the handler in code-behind (copy the body from
DNSLookupView.xaml.cs, change the field name). Make sure using System.Windows.Threading; is present.
- Handler unsubscribes itself; no per-view bool guards needed.
- Test:
- Open the view, run an action that produces results → main column should fill remaining width on the first row appearing, no window resize required.
- Shrink the window below the sum of
MinWidth values → horizontal scrollbar appears.
- Close and re-open the view → behaviour is reproduced (handler re-attaches via XAML on the new instance).
Notes / gotchas
- Don't switch
HorizontalScrollBarVisibility to Disabled — it would hide the scrollbar entirely, contrary to the requirement.
- The
LoadingRow handler only fires when a row actually loads. If a view never has rows (still empty), the column stays at MinWidth, which is acceptable.
- The handler resets all star columns on the grid, so it generalises if a view has more than one star column later.
- If you find a view where the visible result is rendered with something other than a
DataGrid/MultiSelectDataGrid (e.g., ItemsControl, ListView), the WPF bug doesn't apply — adjust column/element widths in the relevant template instead and skip the code-behind workaround.
Acceptance criteria
- All in-scope result views fill the designated star column on first paint without a window resize.
- Horizontal scrollbar still appears when the viewport is narrower than the sum of column
MinWidth values.
- For each view, a deliberate decision is made about
TextWrapping (Wrap or no wrap), recorded in the PR description.
- No regressions in keyboard navigation, sorting, grouping, copy/paste, context menus.
Result DataGrids: main column does not fill remaining width until window resize
Background
The
DNSLookupVieworiginally rendered theResultcolumn at itsMinWidthand only filled the remaining width after the user resized the window. Root cause is a known WPF behaviour: when aDataGridis initially empty andHorizontalScrollBarVisibility="Auto"(default), the innerScrollViewermeasures with infinite width. Star-sized columns (Width="*") then collapse to theirMinWidth. A re-measure is only triggered by a window resize — adding rows alone is not enough.The fix in
DNSLookupViewwas:Width="*"while all earlier columns keepMinWidthonly.HorizontalScrollBarVisibilitystays at the default (Auto) so the horizontal scrollbar still appears when the sum ofMinWidthvalues exceeds the viewport.LoadingRowhandler in code-behind resets star columns once on the first rendered row, forcing the recompute. The handler unsubscribes itself.Reference files:
Source/NETworkManager/Views/DNSLookupView.xaml— column definition withWidth="*",LoadingRowwired up.Source/NETworkManager/Views/DNSLookupView.xaml.cs—DataGridResults_LoadingRowhandler. Includesusing System.Windows.Threading;forDispatcherPriority.Goal
Apply the same pattern to other result-style views so their main "content" column fills the remaining width on first paint and the scrollbar still appears when the window is too narrow. Decide per view whether enabling
TextWrapping="Wrap"on the star column is desirable.Views to audit
Result views (start empty, populated by user action) — primary candidates:
IPScannerView.xaml(usesMultiSelectDataGrid)PortScannerView.xaml(usesMultiSelectDataGrid)TracerouteView.xaml(check control type)SNMPView.xamlSNTPLookupView.xamlWiFiView.xamlLookupPortLookupView.xamlLookupOUILookupView.xamlSubnetCalculatorSubnettingView.xamlPossibly affected (auto-load on view open, but the bug can still bite if first load is async):
ConnectionsView.xamlListenersView.xamlNeighborTableView.xamlFirewallView.xamlNot in scope (data is configured, so the DataGrid usually has content right at first measure):
AboutView.xaml(already usesWidth="*", works because data is synchronous on load)*SettingsView.xaml(DNSLookup,IPScanner,PortScanner,SNMP,SNTP)ProfilesView.xaml,SettingsProfilesView.xamlPortProfilesChildWindow,SNMPOIDProfilesChildWindow,ServerConnectionInfoProfileChildWindow)If during the audit one of these turns out to also start empty, apply the fix there too.
Per-view steps
For each view in scope:
Hostname,Status,Result,Description). For columns where text length varies a lot, this is the right star candidate. Avoid puttingWidth="*"on numeric/short fixed-shape columns (TTL, Port, Class).Width="*"on that column, keepMinWidthas is. Ensure all other columns keepMinWidth(noWidth="*") so the horizontal scrollbar can do its job when the window narrows.TextWrappingcase by case:TextBlock.TextWrapping="Wrap"via<DataGridTextColumn.ElementStyle>only if the column carries variable-length, prose-like content (descriptions, error messages, multi-value DNS results).LoadingRowhandler following theDNSLookupViewtemplate:x:Name="..."to theDataGrid/MultiSelectDataGridif it doesn't have one.LoadingRow="<Name>_LoadingRow"to the XAML element.DNSLookupView.xaml.cs, change the field name). Make sureusing System.Windows.Threading;is present.MinWidthvalues → horizontal scrollbar appears.Notes / gotchas
HorizontalScrollBarVisibilitytoDisabled— it would hide the scrollbar entirely, contrary to the requirement.LoadingRowhandler only fires when a row actually loads. If a view never has rows (still empty), the column stays atMinWidth, which is acceptable.DataGrid/MultiSelectDataGrid(e.g.,ItemsControl,ListView), the WPF bug doesn't apply — adjust column/element widths in the relevant template instead and skip the code-behind workaround.Acceptance criteria
MinWidthvalues.TextWrapping(Wrapor no wrap), recorded in the PR description.