views:

480

answers:

1

This is a rather complex problem that has me really confused right now. Any help would be greatly appreciated.

The Setup:
ListBox of Type A UserControls
->ListBoxItem of Type A UserControl
-->ListBox of Type B UserControls
--->ListBoxItem of Type B UserControl
---->ListBox of Type C UserControls
----->ListBoxItem of Type C UserControl (contains the ComboBox)

In other words, the Type A control has a ListBox of Type B controls that has a ListBox of Type C controls. All of the controls are hierarchical in nature. Type A contains the data that's needed to load the Type B controls and the Type B contains the data that's needed to load the Type C controls. The Type C control has a standard ComboBox in it for changing the values of the present items. In addition to the above structure, I have drag and dropping tied to the PreviewMouseLeftButtonDown event on both the Type A and Type B UserControl levels to handle reordering/deleting/etc commands in the GUI. All of this is working as intended.

The Problem:
When I attempt to change the value in the ComboBox, the SelectionChanged event never fires on the Type C "level" unless I'm careful enough to click on the borders/spacing in between any Type A or B controls. This happens when my ComboBox popout menu overlaps on either a Type A or B control located below itself. The selection events for Type A or B are firing instead of the Type C events, so the ComboBox is never changing its value reliably. In the debugger, the code for handling the drag and drop is triggering on the next ListBoxItem that's located underneath the ComboBox.

Thoughts:
Is there a way I can make my ComboBox popup take prevalence over the items behind it while double-nested in a ListBox (ie, ignore anything behind it while it's open)?
Is there some way to reroute the incorrectly firing SelectionChanged events down to the ComboBox that's supposed to be triggering them?

A: 

So I figured out the answer. I had to add a property to the Type A and B controls that recursively checks down to see if there are any ComboBoxes open. When any of the selection events occur inside the drag and drop functions, I check the property before processing the drag and drop. If there are any ComboBoxes open, I just call Exit Sub and it processes the click event correctly.

Stephen McCusker