From aaef48cd16cba97278b08168295e7d888ad627ac Mon Sep 17 00:00:00 2001 From: Yusyuriv Date: Thu, 2 May 2024 20:48:24 +0600 Subject: [PATCH] Replace Card.GroupPosition with CardGroup.Position attached property --- Flow.Launcher/Resources/Controls/Card.xaml | 6 ++--- Flow.Launcher/Resources/Controls/Card.xaml.cs | 16 ------------- .../Resources/Controls/CardGroup.xaml | 6 ++--- .../Resources/Controls/CardGroup.xaml.cs | 23 +++++++++++++++++++ 4 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Flow.Launcher/Resources/Controls/Card.xaml b/Flow.Launcher/Resources/Controls/Card.xaml index 147c0e650..c29a5f602 100644 --- a/Flow.Launcher/Resources/Controls/Card.xaml +++ b/Flow.Launcher/Resources/Controls/Card.xaml @@ -38,21 +38,21 @@ - + - + - + diff --git a/Flow.Launcher/Resources/Controls/Card.xaml.cs b/Flow.Launcher/Resources/Controls/Card.xaml.cs index db4a136a3..c8f788aca 100644 --- a/Flow.Launcher/Resources/Controls/Card.xaml.cs +++ b/Flow.Launcher/Resources/Controls/Card.xaml.cs @@ -12,27 +12,11 @@ namespace Flow.Launcher.Resources.Controls InsideFit } - public enum CardGroupPosition - { - NotInGroup, - First, - Middle, - Last - } - public Card() { InitializeComponent(); } - public CardGroupPosition GroupPosition - { - get { return (CardGroupPosition)GetValue(GroupPositionProperty); } - set { SetValue(GroupPositionProperty, value); } - } - public static readonly DependencyProperty GroupPositionProperty = - DependencyProperty.Register(nameof(GroupPosition), typeof(CardGroupPosition), typeof(Card), new PropertyMetadata(CardGroupPosition.NotInGroup)); - public string Title { get { return (string)GetValue(TitleProperty); } diff --git a/Flow.Launcher/Resources/Controls/CardGroup.xaml b/Flow.Launcher/Resources/Controls/CardGroup.xaml index 5ea9d1e60..f48bf4b6c 100644 --- a/Flow.Launcher/Resources/Controls/CardGroup.xaml +++ b/Flow.Launcher/Resources/Controls/CardGroup.xaml @@ -9,13 +9,13 @@ d:DesignHeight="300" d:DesignWidth="300"> Content { get { return (ObservableCollection)GetValue(ContentProperty); } @@ -16,6 +24,21 @@ public partial class CardGroup : UserControl public static new readonly DependencyProperty ContentProperty = DependencyProperty.Register(nameof(Content), typeof(ObservableCollection), typeof(CardGroup)); + public static readonly DependencyProperty PositionProperty = DependencyProperty.RegisterAttached( + "Position", typeof(CardGroupPosition), typeof(CardGroup), + new FrameworkPropertyMetadata(CardGroupPosition.NotInGroup, FrameworkPropertyMetadataOptions.AffectsRender) + ); + + public static void SetPosition(UIElement element, CardGroupPosition value) + { + element.SetValue(PositionProperty, value); + } + + public static CardGroupPosition GetPosition(UIElement element) + { + return (CardGroupPosition)element.GetValue(PositionProperty); + } + public CardGroup() { InitializeComponent();