WPF fail

Aug. 10th, 2009 11:02 am
paperclippy: (grr)
[personal profile] paperclippy
According to Reflector, ComboBox has the following code in it:

private static void OnMouseButtonDown(object sender, MouseButtonEventArgs e)
{
    ComboBox box = (ComboBox) sender;
    if (!box.IsContextMenuOpen && !box.IsKeyboardFocusWithin)
    {
        box.Focus();
    }
    e.Handled = true;
    if ((Mouse.Captured == box) && (e.OriginalSource == box))
    {
        box.Close();
    }
}


What does this mean? It means that even if you derive your own ComboBox, you will never receive any MouseDown events. Ever. Unless you hook up a handler to view Handled events.

The result is that if you have a combo box inside a ListBoxItem using a DataTemplate, clicking on the combo box will not select the item in the list, whereas clicking anywhere else in the row will select the item. This is incredibly stupid, and is the cause of a bug for me, since my context menu for the ListBoxItem operates off of the selected items in the list, and you can get into a situation where you open a context menu by right-clicking on the combo box while nothing is selected, and the context menu doesn't know what to display.

WPF, why did you do something so ridiculous? This is kind of like how you have to derive your own ListBox if you want multiselect drag/drop to work. How did this not occur to them?

Profile

paperclippy: (Default)
paperclippy

April 2017

S M T W T F S
      1
2345678
9101112131415
161718 19202122
23242526272829
30      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 21st, 2017 12:17 pm
Powered by Dreamwidth Studios