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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:56:52+00:00 2026-06-18T01:56:52+00:00

Ran into this issue on several occasions. When finding SelectedItem or selected column on

  • 0

Ran into this issue on several occasions.

When finding SelectedItem or selected column on say right click menu or selecting combo box in a cell. The SelectedItem will be null or the previously selected row.

private void ComboBox_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) {
// Correct  
m_BeginEditString = ((ComboBox)sender).SelectedValue.ToString(); 

// Wrong. selected item is last selected row, example clicking directly on combobox will not select row, and be null.
m_BeginEditRow = (RowItem)MyDataGrid.SelectedItem; 
}   

<DataGridTemplateColumn>
   <DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
        <ComboBox SelectedItem="{Binding myItem, Mode=TwoWay, 
NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}" 
ItemsSource="{Binding Source={StaticResource enum}}" 
SelectionChanged="ComboBox_Changed" 
LostKeyboardFocus="ComboBox_LostKeyboardFocus" 
GotKeyboardFocus="ComboBox_GotKeyboardFocus" />
        </DataTemplate>
   </DataGridTemplateColumn.CellTemplate>
 </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-06-18T01:56:53+00:00Added an answer on June 18, 2026 at 1:56 am

    Solved by doing it a completely different way, thanks @Ramesh Muthiah for direction:

    private void ComboBox_Changed(object sender, SelectionChangedEventArgs e) {
    if (((ComboBox)sender).IsLoaded) { // disregard SelectionChangedEvent fired on population from binding
        if (e.RemovedItems.Count != 0) {
            for (Visual visual = (Visual)sender; visual != null; visual = (Visual)VisualTreeHelper.GetParent(visual)) { // Traverse tree to find corred selected item
                if (visual is DataGridRow) {
                    DataGridRow row = (DataGridRow)visual;
                    m_BeginEditRow = new MyRowItem((MyRowItem)row.Item); // Copy constructor, otherwise passed by reference
                    break;
                }
            }
            MyEnum newItem = (MyEnum)e.AddedItems[0];
            MyEnum oldItem = (MyEnum)e.RemovedItems[0];
            if (m_BeginEditRow.Combo1 == newItem) {
                m_BeginEditRow.Combo1 = oldItem;
            } else {
                m_BeginEditRow.Combo2 = oldItem;
            }
            DoStuff(m_BeginEditRow, false);
        }
    }
    

    }

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

Sidebar

Related Questions

I ran into this issue quite a few times. Let's say I have a
I ran into this issue while testing a rails app deployed to two different
I just ran into this issue while making a GET request to a node.js
I've ran into trouble with SOAP, I've never had this issue before and can't
I ran into this issue when trying to add a CMFCMenuButton to an existing
Has anyone ran into this issue? We have a mobile site that can't use
I am taking practice exercises and ran into this issue. This problem asks: Prompt
I recently ran into this issue: I've always used inject like so (i knew
I'm trying to create a website for myself and just ran into this issue:
I ran into this issue earlier in the week and again just now. I'm

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.