I have a column in a gridview that has a hyperlink defined in each row.
<TextBlock>
<Hyperlink Click="btn_Authorise">
<TextBlock Text="{Binding LinkText}"/>
</Hyperlink>
</TextBlock>
I would like the hyperlink to execute different code depending on some parameters I bind to it. ie. the user clicks the link and in the code behind it looks at a parameter and opens one of four dialog windows. How can I add a parameter? Should I be using Commands?
I an new to WPF.
EDIT:
Ok – So all I needed to do was add the CommandParameter=”” and I could then handle the rest in the event handler. This is probably not the correct usage of ‘Commanding’.
<TextBlock>
<Hyperlink Click="btn_Authorise" CommandParameter="{Binding ActionProperty}">
<TextBlock Text="{Binding LinkText}"/>
</Hyperlink>
</TextBlock>
Edit: So apparently Hyperlinks also have commanding, which makes this quite straightforward.
See the commanding overview if you are new to commands in WPF.
You could wrap it in a lookless Button and only handle the Button.Click, then you can bind a Command to it and utilize the CommandParameter.
To make a button lookless you can change the Template: