NullReference exception in DropDownButton.cs

Oct 11, 2010 at 8:29 AM

After I've changed focus to the BrowserControl on my main window display, when I click on a ribbon dropdown button it crashes:

 

protected override void OnPreviewMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e)
{
    if (buttonBorder.IsMouseOver)
    {
        if (!IsDropDownOpen)
        {
            IsDropDownOpen = true;
        }
        else PopupService.RaiseDismissPopupEvent(this, DismissPopupMode.MouseNotOver);
        //Keyboard.Focus(popup);
                //Keyboard.Focus(FocusManager.GetFocusScope(ItemContainerGenerator.ContainerFromIndex(0) as FrameworkElement) as IInputElement);
        Debug.WriteLine(Keyboard.FocusedElement);
        focusedElement = Keyboard.FocusedElement;
        focusedElement.LostKeyboardFocus += OnFocusedElementLostKeyboardFocus;
        focusedElement.PreviewKeyDown += OnFocusedElementPreviewKeyDown;
        e.Handled = true;
    }
}

Keyboard.FocusedElement is the offending item.

Coordinator
Oct 13, 2010 at 8:14 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Oct 13, 2010 at 1:07 PM

Confirmed fixed. Thanks.