1

I have a DataGrid that contains a list of people that have email addresses. What I would like is that when the user clicks on one of the email addresses in the column, a new email is composed in outlook ready for the user to send.

I am currently having issues however with programming the click event on the column, this is what I have so far;

<DataGridHyperlinkColumn Header="Email" Binding="{Binding Email}">
<DataGridHyperlinkColumn.ElementStyle>
    <Style TargetType="TextBlock">
        <EventSetter Event="Hyperlink.Click" Handler="OnHyperlinkClick" />
    </Style>
</DataGridHyperlinkColumn.ElementStyle>

And then the click event;

private void OnHyperlinkClick(object sender, RoutedEventArgs e)
{
    MessageBox.Show("Test");
}

This however causes a crash, stating that it cannot locate the resource and then the users email address. How can I program the click so that it works correctly?

Mafii
  • 7,227
  • 1
  • 35
  • 55
CBreeze
  • 2,925
  • 4
  • 38
  • 93
  • See [this question](http://stackoverflow.com/questions/23020377/link-to-open-new-email-message-in-default-e-mail-handler-in-wpf-application) for some guidance. Also the [DataGridHyperlinkColumn Docs](https://msdn.microsoft.com/en-us/library/system.windows.controls.datagridhyperlinkcolumn(v=vs.110).aspx) has an example of what you are trying to do – Gordon Allocman Mar 24 '16 at 15:36

0 Answers0