mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add Hyperlink component
This commit is contained in:
parent
4be61880dd
commit
1ea00de931
2 changed files with 53 additions and 0 deletions
14
Flow.Launcher/Resources/Controls/HyperLink.xaml
Normal file
14
Flow.Launcher/Resources/Controls/HyperLink.xaml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<UserControl x:Class="Flow.Launcher.Resources.Controls.HyperLink"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<TextBlock>
|
||||
<Hyperlink NavigateUri="{Binding Uri, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
||||
RequestNavigate="Hyperlink_OnRequestNavigate">
|
||||
<Run Text="{Binding Text, RelativeSource={RelativeSource AncestorType=UserControl}}" />
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
</UserControl>
|
||||
39
Flow.Launcher/Resources/Controls/HyperLink.xaml.cs
Normal file
39
Flow.Launcher/Resources/Controls/HyperLink.xaml.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace Flow.Launcher.Resources.Controls;
|
||||
|
||||
public partial class HyperLink : UserControl
|
||||
{
|
||||
public static readonly DependencyProperty UriProperty = DependencyProperty.Register(
|
||||
nameof(Uri), typeof(string), typeof(HyperLink), new PropertyMetadata(default(string))
|
||||
);
|
||||
|
||||
public string Uri
|
||||
{
|
||||
get => (string)GetValue(UriProperty);
|
||||
set => SetValue(UriProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
|
||||
nameof(Text), typeof(string), typeof(HyperLink), new PropertyMetadata(default(string))
|
||||
);
|
||||
|
||||
public string Text
|
||||
{
|
||||
get => (string)GetValue(TextProperty);
|
||||
set => SetValue(TextProperty, value);
|
||||
}
|
||||
|
||||
public HyperLink()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Hyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs e)
|
||||
{
|
||||
App.API.OpenUrl(e.Uri);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue