Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8781359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:16:53+00:00 2026-06-13T20:16:53+00:00

I have a DataGrid with a template column with a Hyperlink as template <DataGridTemplateColumn.CellTemplate>

  • 0

I have a DataGrid with a template column with a Hyperlink as template

<DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
        <TextBlock>
            <Hyperlink Command="{Binding Path=OpenCommand}">
                <TextBlock Text="{Binding Path=Description}" />
            </Hyperlink>
        </TextBlock>
    </DataTemplate>
</DataGridTemplateColumn.CellTemplate>

The DataGrid also have a contextmenu with commands for the selected row. When the user right clicks a row in any other columns than the hyperlink column, the row gets selected and context menu is displayed. The problem I have is when the user right clicks on the hyperlink, in order to see commands for that row, the row does not automatically gets selected.

Question: How can I make the Hyperlink ignore the right mouse click, and let the datagrid take care of the event and select the row just like in the other columns?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:16:54+00:00Added an answer on June 13, 2026 at 8:16 pm

    I’m not sure what causes this behavior, but it sure is annoying.

    I don’t know if you can do something to the Hyperlink or the DataGrid to somehow make it work, but I think not.

    Luckily there is a workaround that works pretty good.

    You can subscribe to the MouseRightButtonDown event on the DataGridRows, and set the IsSelected property to true when the event is raised. That way the correct row will be selected even if you click on the Hyperlink.

    Add the eventhandler in XAML like this:

    <DataGrid.Resources>
        <Style TargetType="DataGridRow">
            <EventSetter Event="MouseRightButtonDown" Handler="DataGridRow_MouseRightButtonDown" />
        </Style>
    </DataGrid.Resources>
    

    ..and in the code-behind set the selection:

    protected void DataGridRow_MouseRightButtonDown(object sender, EventArgs e)
    {
        var row = (DataGridRow)sender;
        row.IsSelected = true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataGrid with template column, containing a checkbox: <DataGridTemplateColumn Header=Foreign key> <DataGridTemplateColumn.CellTemplate>
I have a WPF Datagrid with a Text Column, two Template Columns, and two
I have a Silverlight DataGrid that contains a single template column which displays a
I have a datagrid and a template column which is bound. I don't understand
I have datagrid and inside this grid have template field. I add Header text
Right now I have a datagrid with a template column as follows: <asp:TemplateColumn> <ItemTemplate>
In my Silverlight application I have defined a datagrid with an template column containing
I have a DataGrid template column with ComboBox. When I select a value and
I want my datagrid columns to share a cell/celledit template. I have the solution
I have a DataGridTemplateColumn with DataTemplate as a PasswordBox. I want to warn user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.