Skip to content

Commit

Permalink
borderattach add select style
Browse files Browse the repository at this point in the history
  • Loading branch information
aduskin committed Oct 15, 2023
1 parent 0782540 commit 8b4bd9d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 10 deletions.
36 changes: 36 additions & 0 deletions src/AduSkin/Controls/Attach/BorderAttach.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ public static void SetBorderBrush(DependencyObject element, Brush value)
public static Brush GetBorderBrush(DependencyObject element)
=> (Brush)element.GetValue(BorderBrushProperty);

/// <summary>
/// 选中边框色
/// </summary>
public static readonly DependencyProperty SelectedBorderBrushProperty = DependencyProperty.RegisterAttached(
"SelectedBorderBrush", typeof(Brush), typeof(BorderAttach));

public static void SetSelectedBorderBrush(DependencyObject element, Brush value)
=> element.SetValue(SelectedBorderBrushProperty, value);

public static Brush GetSelectedBorderBrush(DependencyObject element)
=> (Brush)element.GetValue(SelectedBorderBrushProperty);

/// <summary>
/// 边框厚度
/// </summary>
Expand All @@ -32,6 +44,18 @@ public static void SetBorderThickness(DependencyObject element, Thickness value)
public static Thickness GetBorderThickness(DependencyObject element)
=> (Thickness)element.GetValue(BorderThicknessProperty);

/// <summary>
/// 选中边框厚度
/// </summary>
public static readonly DependencyProperty SelectedBorderThicknessProperty = DependencyProperty.RegisterAttached(
"SelectedBorderThickness", typeof(Thickness), typeof(BorderAttach));

public static void SetSelectedBorderThickness(DependencyObject element, Thickness value)
=> element.SetValue(SelectedBorderThicknessProperty, value);

public static Thickness GetSelectedBorderThickness(DependencyObject element)
=> (Thickness)element.GetValue(SelectedBorderThicknessProperty);

/// <summary>
/// 边框圆角
/// </summary>
Expand All @@ -43,5 +67,17 @@ public static void SetCornerRadius(DependencyObject element, CornerRadius value)

public static CornerRadius GetSetCornerRadius(DependencyObject element)
=> (CornerRadius)element.GetValue(BorderThicknessProperty);

/// <summary>
/// 选中边框圆角
/// </summary>
public static readonly DependencyProperty SelectedCornerRadiusProperty = DependencyProperty.RegisterAttached(
"SelectedCornerRadius", typeof(CornerRadius), typeof(BorderAttach));

public static void SetSelectedCornerRadius(DependencyObject element, CornerRadius value)
=> element.SetValue(SelectedCornerRadiusProperty, value);

public static CornerRadius GetSetSelectedCornerRadius(DependencyObject element)
=> (CornerRadius)element.GetValue(BorderThicknessProperty);
}
}
21 changes: 11 additions & 10 deletions src/AduSkin/Themes/Metro/AduRadioButtonIcon.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@
<Setter Property="Foreground" Value="#888" />
<Setter Property="Padding" Value="0" />
<Setter Property="AduAttach:BorderAttach.BorderBrush" Value="Transparent"/>
<Setter Property="AduAttach:BorderAttach.SelectedBorderBrush" Value="Transparent"/>
<Setter Property="AduAttach:BorderAttach.BorderThickness" Value="2,0,0,0"/>
<Setter Property="AduAttach:BorderAttach.SelectedBorderThickness" Value="2,0,0,0"/>
<Setter Property="AduAttach:PathDataAttach.Margin" Value="10,0" />
<Setter Property="AduAttach:PathBrushAttach.NormalPathColor" Value="{StaticResource Brush}"/>
<Setter Property="AduAttach:PathBrushAttach.SelectedPathColor" Value="{StaticResource Brush}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Adu:AduRadioButtonIcon}">
<Border
x:Name="templateRoot"
x:Name="boder"
Background="#00FFFFFF"
Margin="{TemplateBinding Margin}"
Padding="{TemplateBinding Padding}"
BorderBrush="{TemplateBinding AduAttach:BorderAttach.BorderBrush}"
BorderThickness="{TemplateBinding AduAttach:BorderAttach.BorderThickness}">
<StackPanel VerticalAlignment="Center" Orientation="Horizontal" SnapsToDevicePixels="True">
<Border>
<Path x:Name="Icon" VerticalAlignment="Center" Stretch="Uniform"
<Path x:Name="Icon" VerticalAlignment="Center" Stretch="Uniform"
Fill="{TemplateBinding AduAttach:PathBrushAttach.NormalPathColor}"
Width="{TemplateBinding AduAttach:PathDataAttach.Width}"
Margin="{TemplateBinding AduAttach:PathDataAttach.Margin}"
Data="{TemplateBinding AduAttach:PathDataAttach.PathData}" />
</Border>
<TextBlock x:Name="contentPresenter" Grid.Column="1"
<TextBlock x:Name="contentPresenter" Grid.Column="1"
Text="{TemplateBinding Content}"
Foreground="{TemplateBinding AduAttach:PathBrushAttach.NormalPathColor}"
Margin="0,0,5,0" Focusable="False"
Expand All @@ -46,16 +46,17 @@
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True" >
<Setter TargetName="templateRoot" Property="Opacity" Value=".7" />
<Setter TargetName="boder" Property="Opacity" Value=".7" />
</Trigger>
<Trigger Property="IsEnabled" Value="False" />
<Trigger Property="IsPressed" Value="True" />
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="templateRoot" Property="Background" Value="{Binding (AduAttach:BackgroundAttach.SelectedBackground), RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter TargetName="templateRoot" Property="Opacity" Value=".8" />
<Setter TargetName="templateRoot" Property="BorderThickness" Value="2,0,0,0" />
<Setter TargetName="boder" Property="Background" Value="{Binding (AduAttach:BackgroundAttach.SelectedBackground), RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter TargetName="boder" Property="Opacity" Value=".8" />
<Setter TargetName="boder" Property="BorderThickness" Value="{Binding (AduAttach:BorderAttach.SelectedBorderThickness), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
<Setter TargetName="boder" Property="BorderBrush" Value="{Binding (AduAttach:BorderAttach.SelectedBorderBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
<Setter TargetName="Icon" Property="Fill" Value="{Binding (AduAttach:PathBrushAttach.SelectedPathColor), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
<Setter TargetName="templateRoot" Property="BorderBrush" Value="{Binding (AduAttach:PathBrushAttach.SelectedPathColor), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
<Setter TargetName="boder" Property="BorderBrush" Value="{Binding (AduAttach:PathBrushAttach.SelectedPathColor), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
<Setter TargetName="contentPresenter" Property="Foreground" Value="{Binding (AduAttach:PathBrushAttach.SelectedPathColor), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
</Trigger>
</ControlTemplate.Triggers>
Expand Down

0 comments on commit 8b4bd9d

Please sign in to comment.