|
<UserControl x:Class="SimpleControls.Hyperlink.WebHyperlink"
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="50" d:DesignWidth="100"
xmlns:hyperlink="clr-namespace:SimpleControls.Hyperlink"
>
<UserControl.InputBindings>
<KeyBinding Key="C" Modifiers="Ctrl" Command="{x:Static hyperlink:WebHyperlink.CopyUri}"
CommandParameter="{Binding ElementName=PART_Hyperlink,Path=NavigateUri}"/>
</UserControl.InputBindings>
<Grid ToolTip="{Binding ElementName=PART_Hyperlink,Path=NavigateUri}">
<TextBlock TextDecorations="{Binding Path=TextDecorations, RelativeSource={RelativeSource FindAncestor, AncestorType=hyperlink:WebHyperlink, AncestorLevel=1}}">
<Hyperlink Name="PART_Hyperlink"
NavigateUri="{Binding Path=NavigateUri, RelativeSource={RelativeSource FindAncestor, AncestorType=hyperlink:WebHyperlink, AncestorLevel=1}}"
RequestNavigate="Hyperlink_RequestNavigate"
>
<Hyperlink.ContextMenu>
<ContextMenu>
<MenuItem Header="Copy Url to Clipboard"
Command="{x:Static hyperlink:WebHyperlink.CopyUri}"
CommandParameter="{Binding ElementName=PART_Hyperlink, Path=NavigateUri}"
CommandTarget="{Binding PlacementTarget,
RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}}"/>
<MenuItem Header="Open Target in Browser"
Command="{x:Static hyperlink:WebHyperlink.NavigateToUri}"
CommandTarget="{Binding PlacementTarget,
RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}}"/>
</ContextMenu>
</Hyperlink.ContextMenu>
<TextBlock Text="{Binding Path=Text, RelativeSource={RelativeSource FindAncestor, AncestorType=hyperlink:WebHyperlink, AncestorLevel=1}}" />
</Hyperlink>
</TextBlock>
</Grid>
</UserControl>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
The Windows Presentation Foundation (WPF) and C# are among my favorites and so I developed
Edi
and a few other projects on
GitHub. I am normally an algorithms and structure type but WPF has such interesting UI sides that I cannot help myself but get into it.
https://de.linkedin.com/in/dirkbahle