0

I have a derived Combobox control. In Autogeneratingcolumns event, I have assigned FrameworkElemnt of derived combobox as shown below:

        var templateColumn = new DataGridTemplateColumn
            {
                CellTemplate = new DataTemplate
                {
                    VisualTree = derivedComboFrameWorkElement
                }
            };
grid.Column = CreateTemplateColumn(templateColumn);

But, the SelectionChanged event does not fires for the combobox. The funny thing is that, once I inspect the visual tree (GridCell and my ComoboBox) using WPF-Inspector, the SelectionChanged event fires. So doubting that some issue with VisualTree updates. Please help me to get this working properly.

Regards, ani

Ani
  • 3
  • 2
  • Please provide [a minimal, complete and verifiable example](https://stackoverflow.com/help/mcve) which demonstrates the behavior you're [not] seeing. Otherwise you're just asking us to guess wildly, and that's not a productive use of anybody's time. – 15ee8f99-57ff-4f92-890c-b56153 May 17 '18 at 16:13

1 Answers1

0

Good news. Issue has been identified. And the answer is, there was a PreviewMouseDown event and Focus() was called in the event. And thereby the dropdown was closed and was not available for click. I corrected the logic to solve the issue.

To identify this kind of issues, we can make use of WPF Inspector to check visual tree and Snoop which shows all events invoked. Snoop helped me to analyse the issue. Thanks for help.

Regards, ani

Ani
  • 3
  • 2
  • Can you explain more, How you identify the issue, Actually I am also stuck on like the same issue `https://stackoverflow.com/questions/52054862/wpf-combo-box-scrolling-by-mousewheel-works-but-scroll-bar-clicking-does-not?noredirect=1#comment91150447_52054862` – Neeraj Dubey Aug 31 '18 at 12:57