mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Replace Card.GroupPosition with CardGroup.Position attached property
This commit is contained in:
parent
fb6b1bb518
commit
aaef48cd16
4 changed files with 29 additions and 22 deletions
|
|
@ -38,21 +38,21 @@
|
|||
<Setter Property="Background" Value="Transparent" />
|
||||
</DataTrigger>
|
||||
|
||||
<DataTrigger Binding="{Binding GroupPosition, RelativeSource={RelativeSource AncestorType=local:Card}}" Value="First">
|
||||
<DataTrigger Binding="{Binding (local:CardGroup.Position), RelativeSource={RelativeSource AncestorType=local:Card}}" Value="First">
|
||||
<Setter Property="Margin" Value="0" />
|
||||
<Setter Property="CornerRadius" Value="0" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
</DataTrigger>
|
||||
|
||||
<DataTrigger Binding="{Binding GroupPosition, RelativeSource={RelativeSource AncestorType=local:Card}}" Value="Middle">
|
||||
<DataTrigger Binding="{Binding (local:CardGroup.Position), RelativeSource={RelativeSource AncestorType=local:Card}}" Value="Middle">
|
||||
<Setter Property="Margin" Value="0" />
|
||||
<Setter Property="CornerRadius" Value="0" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderThickness" Value="0 1 0 0" />
|
||||
</DataTrigger>
|
||||
|
||||
<DataTrigger Binding="{Binding GroupPosition, RelativeSource={RelativeSource AncestorType=local:Card}}" Value="Last">
|
||||
<DataTrigger Binding="{Binding (local:CardGroup.Position), RelativeSource={RelativeSource AncestorType=local:Card}}" Value="Last">
|
||||
<Setter Property="Margin" Value="0" />
|
||||
<Setter Property="CornerRadius" Value="0" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
|
|
|
|||
|
|
@ -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); }
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@
|
|||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<UserControl.Resources>
|
||||
<Style TargetType="cc:Card" x:Key="FirstStyle">
|
||||
<Setter Property="GroupPosition" Value="First" />
|
||||
<Setter Property="cc:CardGroup.Position" Value="First" />
|
||||
</Style>
|
||||
<Style TargetType="cc:Card" x:Key="MiddleStyle">
|
||||
<Setter Property="GroupPosition" Value="Middle" />
|
||||
<Setter Property="cc:CardGroup.Position" Value="Middle" />
|
||||
</Style>
|
||||
<Style TargetType="cc:Card" x:Key="LastStyle">
|
||||
<Setter Property="GroupPosition" Value="Last" />
|
||||
<Setter Property="cc:CardGroup.Position" Value="Last" />
|
||||
</Style>
|
||||
|
||||
<cc:CardGroupCardStyleSelector
|
||||
|
|
|
|||
|
|
@ -7,6 +7,14 @@ namespace Flow.Launcher.Resources.Controls;
|
|||
|
||||
public partial class CardGroup : UserControl
|
||||
{
|
||||
public enum CardGroupPosition
|
||||
{
|
||||
NotInGroup,
|
||||
First,
|
||||
Middle,
|
||||
Last
|
||||
}
|
||||
|
||||
public new ObservableCollection<Card> Content
|
||||
{
|
||||
get { return (ObservableCollection<Card>)GetValue(ContentProperty); }
|
||||
|
|
@ -16,6 +24,21 @@ public partial class CardGroup : UserControl
|
|||
public static new readonly DependencyProperty ContentProperty =
|
||||
DependencyProperty.Register(nameof(Content), typeof(ObservableCollection<Card>), 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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue