Skip to content

Auto-size sidebar pane to fit the widest menu label#142

Merged
Jack251970 merged 1 commit into
Jack251970:masterfrom
KamilDev:autosize-sidebar-pane
Apr 23, 2026
Merged

Auto-size sidebar pane to fit the widest menu label#142
Jack251970 merged 1 commit into
Jack251970:masterfrom
KamilDev:autosize-sidebar-pane

Conversation

@KamilDev
Copy link
Copy Markdown

Summary

MainWindow.xaml hardcoded NavigationView.OpenPaneLength="185", which was tuned for short Chinese labels. Longer English footer labels ("Software information", "Donate to the author", "Backup and restore") get truncated, as do translations like de-DE "Programmeinstellungen" / "Backup-Wiederherstellung", pt-BR "Configurações do Programa", tr-TR "Yedekleme ve Geri Yükleme", and ru-RU "Поблагодарить автора". WinUI's NavigationView (and therefore iNKORE's WPF port) intentionally exposes OpenPaneLength as a fixed double — there is no PaneSizeMode=Auto or equivalent upstream, so this has to live in the app.

Changes

  • Removes OpenPaneLength="185" from the NavigationView. MainWindow now computes the required pane length at startup by measuring each NavigationViewItem's natural text width with FormattedText (using the NavigationView's effective typeface, font size, and per-monitor DPI) and adding role-specific chrome.
  • Chrome values were measured against iNKORE.UI.WPF.Modern v0.10.2's NavigationViewItem template by instrumenting the real rendered layout (not estimated from theme resources): 100 for expandable parent items (icon + chevron slot), 74 for icon-only footer leaves, 67 for nested leaves without icons.
  • Clamps the result to [185, 400] so the pane never shrinks below the previous width and a pathological translation can't push the pane past the content area. Language changes already call SingleInstance.Restart(), so the calculation runs exactly once per launch.

The previously hardcoded OpenPaneLength="185" clipped English labels
like "Software information", "Donate to the author", and "Backup and
restore", as well as longer translations such as de-DE
"Programmeinstellungen" / "Backup-Wiederherstellung", pt-BR
"Configurações do Programa", tr-TR "Yedekleme ve Geri Yükleme", and
ru-RU "Поблагодарить автора".

Computes the required pane length at startup from the actual labels:
the natural width of each item's text (via FormattedText at the
NavigationView's typeface/size/DPI) plus role-specific chrome
measured against iNKORE.UI.WPF.Modern v0.10.2's NavigationViewItem
template — 100px for expandable parents (icon + chevron slot), 74px
for icon-only footer leaves, 67px for nested leaves. Result is
clamped to [185, 400] so section items with short text don't shrink
the pane below the original width and no single pathological label
eats the content area. Since language changes trigger
SingleInstance.Restart(), the calculation runs exactly once per
launch.
@Jack251970 Jack251970 added the bug Something isn't working label Apr 23, 2026
@Jack251970
Copy link
Copy Markdown
Owner

Thanks for your contribution!

@Jack251970 Jack251970 merged commit 13536f2 into Jack251970:master Apr 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants