diff --git a/components/DataTable/src/DataTable/DataColumn.cs b/components/DataTable/src/DataTable/DataColumn.cs index 6f969b15e..f97e9e4c4 100644 --- a/components/DataTable/src/DataTable/DataColumn.cs +++ b/components/DataTable/src/DataTable/DataColumn.cs @@ -2,8 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Runtime.Versioning; + namespace CommunityToolkit.WinUI.Controls; +[SupportedOSPlatform("osx10.14")] +[SupportedOSPlatform("maccatalyst13.1")] [TemplatePart(Name = nameof(PART_ColumnSizer), Type = typeof(ContentSizer))] public partial class DataColumn : ContentControl { @@ -97,18 +101,18 @@ protected override void OnApplyTemplate() private void PART_ColumnSizer_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e) { - ColumnResizedByUserSizer(); + ColumnResizedByUserSizer(true); } private void PART_ColumnSizer_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e) { - ColumnResizedByUserSizer(); + ColumnResizedByUserSizer(false); } - private void ColumnResizedByUserSizer() + private void ColumnResizedByUserSizer(bool resizing) { // Update our internal representation to be our size now as a fixed value. - CurrentWidth = new(this.ActualWidth); + CurrentWidth = new(this.Width); // Notify the rest of the table to update if (_parent?.TryGetTarget(out DataTable? parent) == true diff --git a/components/DataTable/src/DataTable/DataColumn.xaml b/components/DataTable/src/DataTable/DataColumn.xaml index f88fedfe8..e37db1ce8 100644 --- a/components/DataTable/src/DataTable/DataColumn.xaml +++ b/components/DataTable/src/DataTable/DataColumn.xaml @@ -30,6 +30,7 @@ diff --git a/components/DataTable/src/DataTable/DataRow.cs b/components/DataTable/src/DataTable/DataRow.cs index 6546150ae..ad627d88f 100644 --- a/components/DataTable/src/DataTable/DataRow.cs +++ b/components/DataTable/src/DataTable/DataRow.cs @@ -2,16 +2,21 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Runtime.Versioning; using TreeView = Microsoft.UI.Xaml.Controls.TreeView; namespace CommunityToolkit.WinUI.Controls; +[SupportedOSPlatform("osx10.14")] +[SupportedOSPlatform("maccatalyst13.1")] public partial class DataRow : Panel { // TODO: Create our own helper class here for the Header as well vs. straight-Grid. // TODO: WeakReference? private Panel? _parentPanel; +#pragma warning disable CA2213 private DataTable? _parentTable; +#pragma warning restore CA2213 private bool _isTreeView; private double _treePadding; @@ -42,6 +47,7 @@ private void DataRow_Unloaded(object sender, RoutedEventArgs e) // 1a. Get parent ItemsPresenter to find header if (this.FindAscendant() is ItemsPresenter itemsPresenter) { +#if !HAS_UNO // 2. Quickly check if the header is just what we're looking for. if (itemsPresenter.Header is Grid or DataTable) { @@ -49,14 +55,22 @@ private void DataRow_Unloaded(object sender, RoutedEventArgs e) } else { - // 3. Otherwise, try and find the inner thing we want. - panel = itemsPresenter.FindDescendant(static (element) => element is Grid or DataTable); +#endif + // 3. Use a container from outside + panel = this.FindAscendant()?.Header; + + // 4. Otherwise, try and find the inner thing we want. + panel ??= itemsPresenter.FindDescendant(static (element) => element is Grid or DataTable); +#if !HAS_UNO } +#endif // Check if we're in a TreeView _isTreeView = itemsPresenter.FindAscendant() is TreeView; } + panel ??= this.FindAscendant()?.Header; + // 1b. If we can't find the ItemsPresenter, then we reach up outside to find the next thing we could use as a parent panel ??= this.FindAscendant(static (element) => element is Grid or DataTable); diff --git a/components/DataTable/src/DataTable/DataTable.cs b/components/DataTable/src/DataTable/DataTable.cs index 65a3c1b81..d48a0d8aa 100644 --- a/components/DataTable/src/DataTable/DataTable.cs +++ b/components/DataTable/src/DataTable/DataTable.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; +using System.Runtime.Versioning; namespace CommunityToolkit.WinUI.Controls; @@ -10,6 +11,9 @@ namespace CommunityToolkit.WinUI.Controls; /// A is a which lays out s based on /// their configured properties (akin to ); similar to a with a single row. /// +/// +[SupportedOSPlatform("osx10.14")] +[SupportedOSPlatform("maccatalyst13.1")] public partial class DataTable : Panel { // TODO: We should cache this result and update if column properties change @@ -20,12 +24,14 @@ public partial class DataTable : Panel internal void ColumnResized() { +#pragma warning disable Uno0001 InvalidateArrange(); foreach (var row in Rows) { row.InvalidateArrange(); } +#pragma warning restore Uno0001 } //// TODO: Would we want this named 'Spacing' instead if we support an Orientation in the future for columns being items instead of rows? diff --git a/components/DataTable/src/DataTable/DataTableContainer.cs b/components/DataTable/src/DataTable/DataTableContainer.cs new file mode 100644 index 000000000..dfa6b4b52 --- /dev/null +++ b/components/DataTable/src/DataTable/DataTableContainer.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.Versioning; + +namespace CommunityToolkit.WinUI.Controls; + +[SupportedOSPlatform("osx10.14")] +[SupportedOSPlatform("maccatalyst13.1")] +public partial class DataTableContainer : Grid +{ +#pragma warning disable CA2213 + private Panel? _header; +#pragma warning restore CA2213 + public Panel? Header + { + get + { + if (_header != null) + { + return _header; + } + + if (this.FindDescendant(static (element) => element is Grid or DataTable) is Panel panel) + { + _header = panel; + return _header; + } + + return null; + } + } +} diff --git a/components/DataTable/src/MultiTarget.props b/components/DataTable/src/MultiTarget.props index 18f6c7c98..0db93e06f 100644 --- a/components/DataTable/src/MultiTarget.props +++ b/components/DataTable/src/MultiTarget.props @@ -4,6 +4,6 @@ MultiTarget is a custom property that indicates which target a project is designed to be built for / run on. Used to create project references, generate solution files, enable/disable TargetFrameworks, and build nuget packages. --> - uwp;wasdk; + uwp;wasdk;wasm;linuxgtk;macos;maccatalyst;