Pilot: TableView instead of DataGrid in Show history#12704
Open
niksedk wants to merge 4 commits into
Open
Conversation
DataGrid is in maintenance mode upstream; TableView is the recommended control for read-only tabular data. Show history is SE's simplest grid (read-only, no sorting, no cell themes, no row hacks), so it is used to validate parity before considering wider adoption. Adds headless tests covering what the DataGrid provided: column declaration with Auto/Star widths, row realization and cell binding, selection round-tripping to the view model, and virtualization (2000 items realize 13 rows). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
TableView has no GridLinesVisibility property, so draw the lines as cell borders from the same Appearance.GridLinesAppearance setting (a DataGridGridLinesVisibility name) the DataGrid cell themes use - None, Horizontal, Vertical and All now all behave identically in both controls. TableViewCell's built-in template only template-binds Background, so setting BorderBrush/BorderThickness alone drew nothing; the theme also supplies a template passing them to the ContentPresenter that paints them. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
TableViewRow is a ListBoxItem whose default padding sits outside the cells, so cells were 18px tall inside 39px rows: horizontal lines floated above the row edge and vertical lines were drawn as one short segment per row instead of continuous columns. Zero the row padding so cells fill the row, and move the inset into the cell padding (4px horizontal so text clears the vertical line, vertical from compact mode). Rows are now 22px with cells filling them edge to edge, so the lines join up. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Two leftovers from the pilot's grid lines: - The first row had no line above it: cells only draw bottom borders and the header drew none. The header now draws a bottom line. - The vertical divider did not match between header and rows. TableView insets the header in a Border with hard-coded 6,9,6,12 padding while rows sit flush against the control edge, so the header divider landed 6px right of the cell dividers - and in a different colour, because the built-in header draws its separator as a semi-transparent rectangle inside the resize thumb. Adds a column-header theme matching the cell theme (same brush, same text inset, right + bottom borders) with a template that routes the border properties to the presenter and keeps the PART_Resizer thumb so column resizing still works, and zeroes the header Border's padding on Loaded. Header and cell dividers now share an x, and the header's bottom line sits exactly on the first row's top edge. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Experiment — a single-window pilot of Avalonia 12.1's new
TableView, so we can judge it on real UI before deciding anything broader. Easy to revert.Why this window: Show history is the simplest grid in SE — 2 text columns, read-only, no sorting, no cell themes, no
LoadingRow, no visual-tree drilling, no column persistence. It's also trivially reachable (Edit → Show history) for eyeballing.What changed:
DataGrid→TableView,DataGridTextColumn→TableViewColumn(Bindinginstead of a text-column binding),DataGridLength→GridLength(Auto and 3*Star map 1:1),DataGridSelectionMode.Single→SelectionMode.Single.IsReadOnly/AutoGenerateColumnshave no equivalent and aren't needed — TableView is read-only by design and never auto-generates. TheItemsSource/SelectedItembindings and theSelectionChangedhandler carry over unchanged; the view model is untouched.Verified headlessly (4 new tests): both columns declared with the right width units and
ItemsSourcebound; rows realize and cell text resolves throughTableViewColumn.Binding; settingSelectedIndexround-trips toSelectedHistoryItemand enables the Rollback button; and virtualization works — a 2000-item history realizes 13 rows.Still to judge by eye (can't be asserted headlessly): default row height, header styling, padding and grid-line appearance versus the DataGrid look, since this window doesn't use SE's
DataGridCellcell themes.Natural next step if this looks right:
ReviewSpeechHistoryWindow, which exercisesCellTheme(SE has ~385 uses that would needTableViewCellequivalents) and an interactive buttonCellTemplate.🤖 Generated with Claude Code