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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:08:01+00:00 2026-05-24T09:08:01+00:00

If I have a control (combobox, with a SelectionChanged-event in code-behind) in DataGrid. So,

  • 0

If I have a control (combobox, with a SelectionChanged-event in code-behind) in DataGrid.
So, from _SelectionChanged-event, can I get reference of it’s container-cell of the grid?
Plz Help!!

<DataGridTemplateColumn Width="100">
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
             <TextBlock Text="{Binding Path=QuotationItemCode}"/>
        </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>

    <DataGridTemplateColumn.CellEditingTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">

                <ComboBox Height="22" Width="100"   Name="cmbQuotationItemCode"
                          ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.vwProducts}"
                          DisplayMemberPath="itM_Code" 
                          SelectedValuePath ="itM_Id" 
                          Tag="{Binding RelativeSource={RelativeSource Self}, Path=SelectedItem.Row[2]}"
                          SelectedValue="{Binding Path=QuotationItemId}" 
                          Text="{Binding Path=QuotationItemCode}" SelectionChanged="cmbQuotationItemCode_SelectionChanged">
                </ComboBox>
                <TextBlock Name="txtQuotationItemDescription" Text="{Binding Path=DetailDescription, IsAsync=True}" Height="19"></TextBlock>

            </StackPanel>
        </DataTemplate>
    </DataGridTemplateColumn.CellEditingTemplate>

</DataGridTemplateColumn>
  • 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-24T09:08:03+00:00Added an answer on May 24, 2026 at 9:08 am

    You can walk the visual tree up from the ComboBox until you hit a DataGridCell, using VisualTreeHelper like this:

        private static T FindAncestor<T>(DependencyObject child) where T : DependencyObject
        {
            var parentObject = VisualTreeHelper.GetParent(child);
    
            if(parentObject == null || parentObject is T) {
                return (T)parentObject;
            }
    
            return FindAncestor<T>(parentObject);
        }
    
        private void cmbQuotationItemCode_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var cell = FindAncestor<DataGridCell>((DependencyObject)sender);
            ...
        }
    

    That said, don’t forget about DataGridTemplateColumn.CellStyle – perhaps you can solve your problem with a Style!

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

Sidebar

Related Questions

In WinForms, you have Control.BeginInvoke() , which means you can marshall a call from
The handler of the SelectionChanged event of the ComboBox control has the following signature:
If I have a ComboBox that has a SelectionChanged event, it fires when I'm
I have a control derived from ComboBox , I want to use the ComboBox
I have a combobox control's previewmousewheel event been handled. When my mouse is on
I have a style to a custom control that inherits from combobox that I
I have control (implemented C#, .Net 2.0) that inherits from combobox. It has filtering
I have a user control with a ComboBox and a TextBox. Everything is working
In .net, I have an inherited control: public CustomComboBox : ComboBox I simply want
I have a control,where is combox. I bind to it properties from modelview. I

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.