Make LaunchUriOrFileAction easier to use with Hyperlink
zspitz opened this issue · 1 comments
Describe the bug
Using LaunchUriOrFileAction
together with Hyperlink
feels overcomplicated.
To Reproduce
Try to use Hyperlink
with LaunchUriOrFileAction
. The minimum XAML to do this is AFAICT:
<!--xmlns:b="http://schemas.microsoft.com/xaml/behaviors"-->
<Hyperlink Name="link" NavigateUri="https://github.com/Microsoft/XamlBehaviorsWpf/wiki/LaunchUriOrFileAction">
Link text goes here
<b:Interaction.Triggers>
<b:EventTrigger EventName="RequestNavigate">
<b:LaunchUriOrFileAction Path="{Binding NavigateUri, ElementName=link}" />
</b:EventTrigger>
</b:Interaction.Triggers>
</Hyperlink>
NavigateUri
has to be set because of limitations in Hyperlink
-- the RequestNavigate
event won't fire if NavigateUri
is empty. LaunchUriOrFileAction.Path
has to be set, albeit with a binding to the parent hyperlink's NavigateUri
; but this means the hyperlink also needs a Name
.
Expected behavior
This should be possible with a single line, as Hyperlink and this action are a natural fit together.
Desktop (please complete the following information):
- Version with bug: 1.1.19
- Last known working version: Unknown
Reproduction Link
_testHyperlinkAction.zip
The LaunchUriOrFileAction is specifically designed to be agnostic to the control it is attached to. I don't think this Trigger is the best approach when using a Hyperlink. Honestly, you're better off just using the RequestEvent and calling Process.Start
to open the URI. The amount of XAML you're writing is way more code to achieve the same thing with a simple event.
Modifying this this trigger to specifically handle the Hyperlink will make the use of the trigger API inconsistent with other usages. I don't think this should be something that is added to the trigger.