月更
This commit is contained in:
36
AntDesignWPF/Controls/Hyperlink/Hyperlink.cs
Normal file
36
AntDesignWPF/Controls/Hyperlink/Hyperlink.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
namespace AntDesignWPF.Controls
|
||||
{
|
||||
using System.Windows;
|
||||
using System.Windows.Controls.Primitives;
|
||||
|
||||
/// <summary>
|
||||
/// A hyperlink button.
|
||||
/// </summary>
|
||||
public class Hyperlink : ButtonBase
|
||||
{
|
||||
|
||||
#region Properties
|
||||
|
||||
public static readonly DependencyProperty UriProperty =
|
||||
DependencyProperty.Register("Uri", typeof(string), typeof(Hyperlink), new PropertyMetadata(string.Empty));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the uri of hyperlinks.
|
||||
/// </summary>
|
||||
public string Uri
|
||||
{
|
||||
get { return (string)GetValue(UriProperty); }
|
||||
set { SetValue(UriProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
static Hyperlink()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(Hyperlink), new FrameworkPropertyMetadata(typeof(Hyperlink)));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
40
AntDesignWPF/Controls/Hyperlink/Hyperlink.xaml
Normal file
40
AntDesignWPF/Controls/Hyperlink/Hyperlink.xaml
Normal file
@@ -0,0 +1,40 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:controls="clr-namespace:AntDesignWPF.Controls"
|
||||
xmlns:helpers="clr-namespace:AntDesignWPF.Helpers"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/AntDesignWPF;component/Themes/Converters.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AntDesignWPF;component/Controls/Control.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style BasedOn="{StaticResource Ant.TextElement}" TargetType="{x:Type controls:Hyperlink}">
|
||||
<Setter Property="Background" Value="{x:Null}" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource AntDesign.Brush.Link}" />
|
||||
<Setter Property="helpers:AntControl.MouseOverForeground" Value="{Binding Foreground, Mode=OneWay, ConverterParameter=5, RelativeSource={RelativeSource Self}, Converter={StaticResource ColorPaletteConverter}}" />
|
||||
<Setter Property="helpers:AntControl.PressedForeground" Value="{Binding Foreground, Mode=OneWay, ConverterParameter=7, RelativeSource={RelativeSource Self}, Converter={StaticResource ColorPaletteConverter}}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type controls:Hyperlink}">
|
||||
<Grid Background="{TemplateBinding Background}">
|
||||
<ContentPresenter
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
x:Name="Content" />
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="TextElement.Foreground" TargetName="Content" Value="{Binding Path=(helpers:AntControl.MouseOverForeground), Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="TextElement.Foreground" TargetName="Content" Value="{Binding Path=(helpers:AntControl.PressedForeground), Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user