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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:21:44+00:00 2026-05-26T22:21:44+00:00

In Following WPF Code //class level Variables public TextBox _txtDef = new TextBox(); public

  • 0

In Following WPF Code

//class level Variables
public TextBox _txtDef = new TextBox(); 
public TextBox _txtComment = new TextBox();

//Events
private void OnCommentsMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
    _txtComment = sender as TextBox;
}

private void OnDefinitionMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
    _txtDef = sender as TextBox;
}

Markup

<WPFtoolkit:DataGridTemplateColumn x:Name="dgDefinition" Header="Definition" 
                                           Visibility="Collapsed" Width="300">
  <WPFtoolkit:DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
      <TextBlock Text="{Binding Path=Definition, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
    </DataTemplate>
  </WPFtoolkit:DataGridTemplateColumn.CellTemplate>
  <WPFtoolkit:DataGridTemplateColumn.CellEditingTemplate>
    <DataTemplate>
      <TextBox x:Name="txtDefinition" 
               Text="{Binding Path=Definition, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
               BorderThickness="0" ContextMenuOpening="DefinitionContextMenuOpen"
               MouseDoubleClick="OnDefinitionMouseDoubleClick">
      </TextBox>
    </DataTemplate>
  </WPFtoolkit:DataGridTemplateColumn.CellEditingTemplate>
</WPFtoolkit:DataGridTemplateColumn>

<WPFtoolkit:DataGridTemplateColumn x:Name="dgComment" Header="Comment" Width="200"
                                   Visibility="Collapsed">
  <WPFtoolkit:DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
      <TextBlock Text="{Binding Path=Comment, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
    </DataTemplate>
  </WPFtoolkit:DataGridTemplateColumn.CellTemplate>
  <WPFtoolkit:DataGridTemplateColumn.CellEditingTemplate>
    <DataTemplate>
      <TextBox x:Name="txtComment" 
               Text="{Binding Path=Comment, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
               BorderThickness="0" MouseDoubleClick="OnCommentsMouseDoubleClick">
      </TextBox>
    </DataTemplate>
  </WPFtoolkit:DataGridTemplateColumn.CellEditingTemplate>
</WPFtoolkit:DataGridTemplateColumn>   

When I m clicking on a particular cell one of the two event mentioned above get fired and hence only the reference of that particular textbox get added whose event get fired.

Is there any way to add the reference of both textbox while any of the two event get fired.

Thanks

  • 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-26T22:21:44+00:00Added an answer on May 26, 2026 at 10:21 pm

    Unfortunately not (IMO). You wrote a DataTemplate. This will instanciated for each entry in your grid. When the event is fired, you will get the TextBox as sender the event was fired for (as you already mentioned). But I don’t see any chance to get the instance of the other TextBox (it may not be instanciated already)

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

Sidebar

Related Questions

I have the following WPF code: public Window1() { InitializeComponent(); FlowDocument fd = new
I am NEW to WPF. I have the following XAML code: </Window> ... <Canvas>
Given the following code from a Microsoft example: public class EngineMeasurementCollection : Collection<EngineMeasurement> {
In my WPF app, all I have in my code-behind is the following: public
The following ToolTip code works in WPF . I'm trying to get it to
Im trying to load a image at runtime in WPF using the following code
I am trying my hands on WPF MVVM. I have written following code in
The following code is a silverlight application but the same happens in WPF, so
I am using a base Window class in a WPF project. In the code
I have the following DTO definition:- [DataContract] public class AddProductDTO { [DataMember] public string

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.