From bac1629836881290f96372dfa5d6b7ddb8803645 Mon Sep 17 00:00:00 2001 From: Niels Laute Date: Tue, 11 Jul 2023 16:43:52 +0200 Subject: [PATCH] Switch to Toolkit components --- components/DataTable/src/Dependencies.props | 2 + .../HeaderedItemsControl.cs | 121 ----------------- .../HeaderedItemsControl.xaml | 18 --- .../src/HeaderedTreeView/HeaderedTreeView.cs | 126 ------------------ .../HeaderedTreeView/HeaderedTreeView.xaml | 39 ------ 5 files changed, 2 insertions(+), 304 deletions(-) delete mode 100644 components/DataTable/src/HeaderedItemsControl/HeaderedItemsControl.cs delete mode 100644 components/DataTable/src/HeaderedItemsControl/HeaderedItemsControl.xaml delete mode 100644 components/DataTable/src/HeaderedTreeView/HeaderedTreeView.cs delete mode 100644 components/DataTable/src/HeaderedTreeView/HeaderedTreeView.xaml diff --git a/components/DataTable/src/Dependencies.props b/components/DataTable/src/Dependencies.props index be4306195..502311afe 100644 --- a/components/DataTable/src/Dependencies.props +++ b/components/DataTable/src/Dependencies.props @@ -17,6 +17,7 @@ + @@ -24,5 +25,6 @@ + diff --git a/components/DataTable/src/HeaderedItemsControl/HeaderedItemsControl.cs b/components/DataTable/src/HeaderedItemsControl/HeaderedItemsControl.cs deleted file mode 100644 index ae194529e..000000000 --- a/components/DataTable/src/HeaderedItemsControl/HeaderedItemsControl.cs +++ /dev/null @@ -1,121 +0,0 @@ -// 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. - -namespace CommunityToolkit.WinUI.Controls; - -/// -/// Represents a control that contains multiple items and has a header. -/// -public partial class HeaderedItemsControl : ItemsControl -{ - /// - /// Initializes a new instance of the class. - /// - public HeaderedItemsControl() - { - DefaultStyleKey = typeof(HeaderedItemsControl); - } - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty FooterProperty = DependencyProperty.Register( - nameof(Footer), - typeof(object), - typeof(HeaderedItemsControl), - new PropertyMetadata(null, OnFooterChanged)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty FooterTemplateProperty = DependencyProperty.Register( - nameof(FooterTemplate), - typeof(DataTemplate), - typeof(HeaderedItemsControl), - new PropertyMetadata(null)); - - /// - /// Gets or sets the data used for the Footer of each control. - /// - public object Footer - { - get { return GetValue(FooterProperty); } - set { SetValue(FooterProperty, value); } - } - - /// - /// Gets or sets the template used to display the content of the control's Footer. - /// - public DataTemplate FooterTemplate - { - get { return (DataTemplate)GetValue(FooterTemplateProperty); } - set { SetValue(FooterTemplateProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register( - nameof(Header), - typeof(object), - typeof(HeaderedItemsControl), - new PropertyMetadata(null, OnHeaderChanged)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty HeaderTemplateProperty = DependencyProperty.Register( - nameof(HeaderTemplate), - typeof(DataTemplate), - typeof(HeaderedItemsControl), - new PropertyMetadata(null)); - - /// - /// Gets or sets the data used for the header of each control. - /// - public object Header - { - get { return GetValue(HeaderProperty); } - set { SetValue(HeaderProperty, value); } - } - - /// - /// Gets or sets the template used to display the content of the control's header. - /// - public DataTemplate HeaderTemplate - { - get { return (DataTemplate)GetValue(HeaderTemplateProperty); } - set { SetValue(HeaderTemplateProperty, value); } - } - - /// - /// Called when the property changes. - /// - /// The old value of the property. - /// The new value of the property. - protected virtual void OnFooterChanged(object oldValue, object newValue) - { - } - - private static void OnFooterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var control = (HeaderedItemsControl)d; - control.OnFooterChanged(e.OldValue, e.NewValue); - } - - /// - /// Called when the property changes. - /// - /// The old value of the property. - /// The new value of the property. - protected virtual void OnHeaderChanged(object oldValue, object newValue) - { - } - - private static void OnHeaderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var control = (HeaderedItemsControl)d; - control.OnHeaderChanged(e.OldValue, e.NewValue); - } -} diff --git a/components/DataTable/src/HeaderedItemsControl/HeaderedItemsControl.xaml b/components/DataTable/src/HeaderedItemsControl/HeaderedItemsControl.xaml deleted file mode 100644 index 8085e90b7..000000000 --- a/components/DataTable/src/HeaderedItemsControl/HeaderedItemsControl.xaml +++ /dev/null @@ -1,18 +0,0 @@ - - - diff --git a/components/DataTable/src/HeaderedTreeView/HeaderedTreeView.cs b/components/DataTable/src/HeaderedTreeView/HeaderedTreeView.cs deleted file mode 100644 index 4d4525f10..000000000 --- a/components/DataTable/src/HeaderedTreeView/HeaderedTreeView.cs +++ /dev/null @@ -1,126 +0,0 @@ -// 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 TreeView = Microsoft.UI.Xaml.Controls.TreeView; - -namespace CommunityToolkit.WinUI.Controls; - -/// -/// Represents a and has a header. -/// -public partial class HeaderedTreeView : TreeView -{ - /// - /// Initializes a new instance of the class. - /// - public HeaderedTreeView() - { - DefaultStyleKey = typeof(HeaderedTreeView); - - // Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/3502 - this.DefaultStyleResourceUri = new Uri("ms-appx:///CommunityToolkit.WinUI.Controls.DataTable/Themes/Generic.xaml"); - } - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty FooterProperty = DependencyProperty.Register( - nameof(Footer), - typeof(object), - typeof(HeaderedTreeView), - new PropertyMetadata(null, OnFooterChanged)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty FooterTemplateProperty = DependencyProperty.Register( - nameof(FooterTemplate), - typeof(DataTemplate), - typeof(HeaderedTreeView), - new PropertyMetadata(null)); - - /// - /// Gets or sets the data used for the Footer of each control. - /// - public object Footer - { - get { return GetValue(FooterProperty); } - set { SetValue(FooterProperty, value); } - } - - /// - /// Gets or sets the template used to display the content of the control's Footer. - /// - public DataTemplate FooterTemplate - { - get { return (DataTemplate)GetValue(FooterTemplateProperty); } - set { SetValue(FooterTemplateProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register( - nameof(Header), - typeof(object), - typeof(HeaderedTreeView), - new PropertyMetadata(null, OnHeaderChanged)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty HeaderTemplateProperty = DependencyProperty.Register( - nameof(HeaderTemplate), - typeof(DataTemplate), - typeof(HeaderedTreeView), - new PropertyMetadata(null)); - - /// - /// Gets or sets the data used for the header of each control. - /// - public object Header - { - get { return GetValue(HeaderProperty); } - set { SetValue(HeaderProperty, value); } - } - - /// - /// Gets or sets the template used to display the content of the control's header. - /// - public DataTemplate HeaderTemplate - { - get { return (DataTemplate)GetValue(HeaderTemplateProperty); } - set { SetValue(HeaderTemplateProperty, value); } - } - - /// - /// Called when the property changes. - /// - /// The old value of the property. - /// The new value of the property. - protected virtual void OnFooterChanged(object oldValue, object newValue) - { - } - - private static void OnFooterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var control = (HeaderedTreeView)d; - control.OnFooterChanged(e.OldValue, e.NewValue); - } - - /// - /// Called when the property changes. - /// - /// The old value of the property. - /// The new value of the property. - protected virtual void OnHeaderChanged(object oldValue, object newValue) - { - } - - private static void OnHeaderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var control = (HeaderedTreeView)d; - control.OnHeaderChanged(e.OldValue, e.NewValue); - } -} diff --git a/components/DataTable/src/HeaderedTreeView/HeaderedTreeView.xaml b/components/DataTable/src/HeaderedTreeView/HeaderedTreeView.xaml deleted file mode 100644 index b8097f3ef..000000000 --- a/components/DataTable/src/HeaderedTreeView/HeaderedTreeView.xaml +++ /dev/null @@ -1,39 +0,0 @@ - - - -