Fixed event handler for StackPanel.