From 8a7f10d5597a197d357e0c8b480872c02cc63613 Mon Sep 17 00:00:00 2001 From: Michael Hawker <24302614+michael-hawker@users.noreply.github.com> Date: Tue, 28 Apr 2026 10:33:53 -0700 Subject: [PATCH] Fix for DataColumn to resize with keyboard See issue https://github.com/CommunityToolkit/Windows/issues/849 from the Toolkit where it's hard for us to respond here, we need a bit of thinking about how to best respond here. --- components/DataTable/src/DataTable/DataColumn.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/DataTable/src/DataTable/DataColumn.cs b/components/DataTable/src/DataTable/DataColumn.cs index b5a6ea143..619ef9daa 100644 --- a/components/DataTable/src/DataTable/DataColumn.cs +++ b/components/DataTable/src/DataTable/DataColumn.cs @@ -81,6 +81,7 @@ protected override void OnApplyTemplate() PART_ColumnSizer.TargetControl = null; PART_ColumnSizer.ManipulationDelta -= this.PART_ColumnSizer_ManipulationDelta; PART_ColumnSizer.ManipulationCompleted -= this.PART_ColumnSizer_ManipulationCompleted; + PART_ColumnSizer.KeyUp -= this.PART_ColumnSizer_KeyUp; } PART_ColumnSizer = GetTemplateChild(nameof(PART_ColumnSizer)) as ContentSizer; @@ -90,6 +91,7 @@ protected override void OnApplyTemplate() PART_ColumnSizer.TargetControl = this; PART_ColumnSizer.ManipulationDelta += this.PART_ColumnSizer_ManipulationDelta; PART_ColumnSizer.ManipulationCompleted += this.PART_ColumnSizer_ManipulationCompleted; + PART_ColumnSizer.KeyUp += this.PART_ColumnSizer_KeyUp; } // Get DataTable parent weak reference for when we manipulate columns. @@ -102,6 +104,11 @@ protected override void OnApplyTemplate() base.OnApplyTemplate(); } + private void PART_ColumnSizer_KeyUp(object sender, KeyRoutedEventArgs e) + { + ColumnResizedByUserSizer(); + } + private void PART_ColumnSizer_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e) { ColumnResizedByUserSizer();