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 4578862
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:33:42+00:00 2026-05-21T20:33:42+00:00

I have code where I can take a look at the SelectedItem and then

  • 0

I have code where I can take a look at the SelectedItem and then output ToString() to get the record into the clipboard.

How can I detect what cell the user is right clicking on in order to copy just that cell in the SelectedItem?

For example, if I have Borrower Information and the user right-clicks on last name, I would like to give the ability to just copy last name to clipboard.

Thank you!

UPDATE:

Here is the code that I used as suggested by Josh, it worked great:

  private void BorrowerInfoCopyClicked(object sender, RoutedEventArgs e)
        {
            BorrowerViewModel vm = this.DataContext as BorrowerViewModel;
            if (vm != null)
            {
                Clipboard.SetData(DataFormats.Text, vm.CurrentTextBlockText);
            }
        }

        private void AddressCopyClicked(object sender, RoutedEventArgs e)
        {
            BorrowerViewModel vm = this.DataContext as BorrowerViewModel;
            if (vm != null)
            {
                Clipboard.SetData(DataFormats.Text, vm.CurrentTextBlockText);
            }
        }

        private void lstViews_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            BorrowerViewModel vm = this.DataContext as BorrowerViewModel;
            if (vm != null)
            {
                if (e.OriginalSource is TextBlock)
                {
                    TextBlock txtBlock = e.OriginalSource as TextBlock;
                    vm.CurrentTextBlockText = txtBlock.Text;
                }

}
}

  • 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-05-21T20:33:43+00:00Added an answer on May 21, 2026 at 8:33 pm

    I’ve done this by handling the PreviewMouseRightButtonDown event on the ListView and checking if e.OriginalSource is a TextBlock. If so, copy the txtBlk.Text to the clipboard. This code could either be in the code-behind of the View that contains the ListView, or as a behavior you attach to the ListView. If you need to use a context menu to perform the Copy operation, have a TextBlock field that you use to store a reference to the TextBlock, and in your method that responds to a MenuItem’s click (or Command execution) reference the TextBlock there instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, if I have this right, my code can get cookies at a specific
Logging can get complicated, quickly. Considering that you have some code, how do you
Following on from this question I now have code that can attach to a
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
Does anybody have a short code sample that can be run in the VS
We have similar code to the following in one of our projects. Can anyone
I have some code which returns InnerXML for a XMLNode. The node can contain
If you have Mathematica code in foo.m, Mathematica can be invoked with -noprompt and
We have a project that generates a code snippet that can be used on
I have a custom XML file format which can contain blocks of code within

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.